Skip to content

Commit b5ec33f

Browse files
committed
added ridgeline plot
1 parent 61827c3 commit b5ec33f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

notebooks/violin.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,30 @@ fig.update_layout(
236236
fig.show()
237237
```
238238

239+
#### Ridgeline plot
240+
241+
A ridgeline plot ([previously known as Joy Plot](https://serialmentor.com/blog/2017/9/15/goodbye-joyplots)) shows the distribution of a numerical value for several groups. They can be used for visualizing changes in distributions over time or space.
242+
243+
```python
244+
import plotly.graph_objects as go
245+
from plotly.colors import n_colors
246+
import numpy as np
247+
248+
# 12 sets of normal distributed random data, with increasing mean and standard deviation
249+
data = (np.linspace(1, 2, 12)[:, np.newaxis] * np.random.randn(12, 200) +
250+
(np.arange(12) + 2 * np.random.random(12))[:, np.newaxis])
251+
252+
colors = n_colors('rgb(5, 200, 200)', 'rgb(200, 10, 10)', 12, colortype='rgb')
253+
254+
fig = go.Figure()
255+
for data_line, color in zip(data, colors):
256+
fig.add_trace(go.Violin(x=data_line, line_color=color))
257+
258+
fig.update_traces(orientation='h', side='positive', width=3, points=False)
259+
fig.update_layout(xaxis_showgrid=False, xaxis_zeroline=False)
260+
fig.show()
261+
```
262+
239263
#### Reference
240264
See https://plot.ly/python/reference/#violin for more information and chart attribute options!
241265

0 commit comments

Comments
 (0)