# Grouped and split violin plot possible?

**URL:** <https://community.plotly.com/t/grouped-and-split-violin-plot-possible/37350>\
**Category:** 📊 Plotly Python\
**Created:** [April 7, 2020, 3:41am UTC](https://community.plotly.com/t/grouped-and-split-violin-plot-possible/37350 "2020-04-07T03:41:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![juls858](https://avatars.discourse-cdn.com/v4/letter/j/ac8455/32.png) [@juls858](https://community.plotly.com/u/juls858)\
**Post date:** [April 7, 2020, 3:41am UTC](https://community.plotly.com/t/grouped-and-split-violin-plot-possible/37350/1 "2020-04-07T03:41:48Z")

</div>

is it possible to have a combination group and split violin plot?

> **[Violin Plots](https://plotly.com/python/violin/#violin-plot-with-goviolin)**
>
> How to make violin plots in Python with Plotly.

I can’t seem to figure out how to do this.

I’d like to be able to have multiple split violins per group in x.

---

<div class="post-metadata">

**Author:** ![Emmanuelle](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emmanuelle/32/7853_2.png) [@Emmanuelle](https://community.plotly.com/u/Emmanuelle)\
**Post date:** [April 7, 2020, 9:49am UTC](https://community.plotly.com/t/grouped-and-split-violin-plot-possible/37350/2 "2020-04-07T09:49:39Z")

</div>

Hi @juls858 welcome to the forum! You can have only one `violinmode` in the `layout` so you cannot have both `overlay` (which you need to make split violin plot) and `group`. However, what you can do is to use [multicategory axes](https://plotly.com/python/axes/#subcategory-multicategory-axes) to group several split plots with the same label. I quickly adapted the example of the doc to show below how this can be done. Hope this helps!

```auto
import plotly.graph_objects as go

import pandas as pd

df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/violin_data.csv")

fig = go.Figure()

days_yes = df['day'][df['smoker'] == 'Yes']
grouped_labels_yes = days_yes.map({"Thur":"A", "Fri":"A", "Sat":"B", "Sun":"B"})
days_no = df['day'][df['smoker'] == 'No']
grouped_labels_no = days_no.map({"Thur":"A", "Fri":"A", "Sat":"B", "Sun":"B"})

fig.add_trace(go.Violin(x=[grouped_labels_yes, days_yes],
                        y=df['total_bill'][df['smoker'] == 'Yes' ],
                        legendgroup='Yes', scalegroup='Yes', name='Yes',
                        side='negative',
                        line_color='blue')
             )
fig.add_trace(go.Violin(x=[grouped_labels_no, days_no],
                        y=df['total_bill'][df['smoker'] == 'No' ],
                        legendgroup='No', scalegroup='No', name='No',
                        side='positive',
                        line_color='orange')
             )
fig.update_traces(meanline_visible=True)
fig.update_layout(violingap=0, violinmode='overlay')
fig.show()

```

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/1/1a557384987edd4733aca18961c7091ad4dcdde7.png)

---

<div class="post-metadata">

**Author:** ![juls858](https://avatars.discourse-cdn.com/v4/letter/j/ac8455/32.png) [@juls858](https://community.plotly.com/u/juls858)\
**Post date:** [April 7, 2020, 6:56pm UTC](https://community.plotly.com/t/grouped-and-split-violin-plot-possible/37350/3 "2020-04-07T18:56:43Z")

</div>

This works great thanks! Is there an easy way to hide a level of labels?
