Black Lives Matter. Please consider donating to Black Girls Code today.

Staggered/Stacked Histogram Plots

I’d like to create a plot of staggered histograms like so:

I could find Stack Overflow links on how to do this in R ( and Python’s matplotlib ( How does one accomplish this in plotly?

Hi @RylanSchaeffer, you can find an example of ridgeline plot in the violin chart tutorial.

Amazing! I didn’t know what they were called. Ridgeline! Thank you!

@Emmanuelle Following the Ridgeline plot you refer to I tried to reproduce it, but instead of using a go.Violin I need to use px.scatter. So, from this minimal working version of the code:

fig = go.Figure()
for i in range(5):
    fig.add_trace(go.Violin(x=[0,2,6], line_color=color))

I created this:

fig = go.Figure()
for i in range(5):
    fig_i = px.scatter(x=[0,2,6], y=[5,10,5])

But when I use scatter I don’t get multiple traces, but just one. How can I make a Ridgeline plot with scattered data? Does plotly only do Ridgeline plots with go.Violin? Is there some workaround that would help in my case? Thanks