# Bug? Plotly violins use only the first letters of 'by' categories

**URL:** <https://discourse.holoviz.org/t/bug-plotly-violins-use-only-the-first-letters-of-by-categories/7224>\
**Category:** hvPlot\
**Created:** [May 9, 2024, 4:01am UTC](https://discourse.holoviz.org/t/bug-plotly-violins-use-only-the-first-letters-of-by-categories/7224 "2024-05-09T04:01:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sam-spence](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/sam-spence/32/6598_2.png) [@sam-spence](https://discourse.holoviz.org/u/sam-spence)\
**Post date:** [May 9, 2024, 4:01am UTC](https://discourse.holoviz.org/t/bug-plotly-violins-use-only-the-first-letters-of-by-categories/7224/1 "2024-05-09T04:01:55Z")

</div>

When making violin plots with the ‘by’ argument to make a separate violin for each data category, hvplot (plotly extension) doesn’t use the category names properly. Instead of one violin for each category, it takes the first letter of each category and stacks violins which have the same first letter. It also prints only the first letter of each category in the legend.

This seems to not happen with the bokeh extension, which creates one violin per category as expected.

An example of the expected behaviour, that occurs when using the bokeh extension  
from the hvplot documentation [here](https://hvplot.holoviz.org/reference/tabular/violin.html). As you expect from a violin plot, there is one violin for each category (in this example they start with different letters, but it also works as expected when they start with the same letter).

There is an example of the unexpected behaviour in the hvplot documentation [here](https://hvplot.holoviz.org/user_guide/Plotting_with_Plotly.html#groupby). The two letter carrier categories eg OO and OH are stacked because they both start with O.

Also,

 ![my plotly](https://discourse.holoviz.org/uploads/default/original/2X/2/287f1920ae508259695e8d2bc1c60c69acb42559.png)  
from my own data. All categories that start with the same letter are stacked instead of separate, e.g. Ascomycota and Actinobacteria don’t get their own violin with the category’s name under the x axis; instead they are all stacked on top of each other in the ‘A’ group. The legend also only lists the first letter of each category.

This can be reproduced simply with df.hvplot.violin(y=numerical\_column, by=categorical/string\_column). I have been trying a lot of other arguments to try and make plotly work properly, with no success.

This is surely a bug and not the intended behaviour, right? I would prefer to use the plotly extension because the graphs look a lot nicer than bokeh’s. Is there a way to make it draw the violin plot properly?

Many thanks

---

<div class="post-metadata">

**Author:** ![ahuang11](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/ahuang11/32/4947_2.png) [@ahuang11](https://discourse.holoviz.org/u/ahuang11)\
**Post date:** [May 10, 2024, 10:29pm UTC](https://discourse.holoviz.org/t/bug-plotly-violins-use-only-the-first-letters-of-by-categories/7224/2 "2024-05-10T22:29:54Z")

</div>

It could be a bug; could you share a minimal example that we could copy/paste/run to confirm?

---

<div class="post-metadata">

**Author:** ![sam-spence](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/sam-spence/32/6598_2.png) [@sam-spence](https://discourse.holoviz.org/u/sam-spence)\
**Post date:** [May 14, 2024, 3:16am UTC](https://discourse.holoviz.org/t/bug-plotly-violins-use-only-the-first-letters-of-by-categories/7224/3 "2024-05-14T03:16:28Z")

</div>

You can follow the example on the hvplot documentation for plotly and bokeh at  
[https://hvplot.holoviz.org/user\_guide/Plotting\_with\_Plotly.html#groupby](https://hvplot.holoviz.org/user_guide/Plotting_with_Plotly.html#groupby)  
[https://hvplot.holoviz.org/user\_guide/Plotting.html](https://hvplot.holoviz.org/user_guide/Plotting.html)  
The documentation itself shows the bugged plotly graph and the correct bokeh graph.

```auto
import numpy as np
import hvplot.pandas
import hvplot.dask
hvplot.extension('plotly')
from hvplot.sample_data import us_crime, airline_flights
flights = airline_flights.to_dask().persist()
a=flights.hvplot.violin(y='depdelay', by='carrier', groupby='dayofweek', ylim=(-20, 60), height=500)
hvplot.show(a)
hvplot.extension('bokeh')
b=flights.hvplot.violin(y='depdelay', by='carrier', groupby='dayofweek', ylim=(-20, 60), height=500)
hvplot.show(b)

```

---

<div class="post-metadata">

**Author:** ![ahuang11](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/ahuang11/32/4947_2.png) [@ahuang11](https://discourse.holoviz.org/u/ahuang11)\
**Post date:** [May 14, 2024, 9:34pm UTC](https://discourse.holoviz.org/t/bug-plotly-violins-use-only-the-first-letters-of-by-categories/7224/4 "2024-05-14T21:34:22Z")

</div>

Thanks can you file a report on HoloViews?

---

<div class="post-metadata">

**Author:** ![sam-spence](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/sam-spence/32/6598_2.png) [@sam-spence](https://discourse.holoviz.org/u/sam-spence)\
**Post date:** [May 15, 2024, 4:01am UTC](https://discourse.holoviz.org/t/bug-plotly-violins-use-only-the-first-letters-of-by-categories/7224/5 "2024-05-15T04:01:48Z")

</div>

On the holoviews github?

---

<div class="post-metadata">

**Author:** ![ahuang11](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/ahuang11/32/4947_2.png) [@ahuang11](https://discourse.holoviz.org/u/ahuang11)\
**Post date:** [May 15, 2024, 3:40pm UTC](https://discourse.holoviz.org/t/bug-plotly-violins-use-only-the-first-letters-of-by-categories/7224/6 "2024-05-15T15:40:21Z")

</div>

Yup
