-
-
Notifications
You must be signed in to change notification settings - Fork 1
Ridgeline Plot #25
Comments
Thanks for getting back to this and the quick implementation. I haven't had the time yet to return to this but I'm definitely looking forward to using this. |
I would like to use a ridgelin plot in plotly, but unfortunately, from what I see it is bound to using |
You could use |
@nicolaskruchten Thanks for the advice, I will look now into |
This is nice ... but I've struggled to remove the transparency and ensure that the bottom plot is drawn on top. I've put a post up in the community (https://community.plotly.com/t/ridgeline-joy-plot-without-transparency/55028?u=maegul), on the hacks I went through to do it (see eg below), but I think it's related to this issue because this stylistic choice is pretty common for ridgeline plots and, I'd say, pretty desirable too. The z-order issue is also related: plotly/plotly.py#2345 import plotly.graph_objects as go
from plotly.colors import n_colors
import numpy as np
np.random.seed(1)
data = (np.linspace(1, 2, 12)[:, np.newaxis] * np.random.randn(12, 200) +
(np.arange(12) + 2 * np.random.random(12))[:, np.newaxis])
colors = n_colors('rgb(5, 200, 200)', 'rgb(200, 10, 10)', 12, colortype='rgb')
fig = go.Figure()
for i, (data_line, color) in enumerate(zip(data, colors)):
fig.add_trace(
go.Violin(x=data_line, line_color='black', name=i, fillcolor=color)
)
# use negative ... cuz I'm gonna flip things later
fig = fig.update_traces(orientation='h', side='negative', width=3, points=False, opacity=1)
# reverse the (z)-order of the traces
fig.data = fig.data[::-1]
# flip the y axis (negative violin is now positive and traces on the top are now on the bottom)
fig.update_layout(legend_traceorder='reversed', yaxis_autorange='reversed').show() |
So I'm having issues with this approach when y-axis or trace identifier or name is not quantitative. In such cases, the I haven't got a good example ready yet ... but I think it occurs with the y-axis datatype is datetime ... ? This is presumably, again, a problem at the JS level. |
Loving these plots. I noticed that the violins collapse when using a DateTime column:
Changing the width has no effect. Is this inevitable with a continuous variable? It's not a huge pain to convert 'dt' to a string, but would be nice to use 'dt' directly. |
I ran into this issue in the past and decided to build a little fun side project just for this use-case. I'll plug it here in case it can be of help to anyone that runs across this issue: https://github.com/tpvasconcelos/ridgeplot |
Hi. It would be great if there was support for a Ridgeline plot since it's a bit tedious to implement it manually. This has been discussed for plotly before:
It could be introduced as
px.ridgeline()
orpx.violin(ridgeline=True)
. The latter would be great if the same can be achieved for histograms or scatter plots in general.For inspiration, you can also have a look at https://www.tensorflow.org/guide/tensorboard_histograms
Nice implementation detail from the link:
Another useful thing is the x-axis line across the image for a better comparison across the y axis. The highlight of the x and y axis label don't seem to work in the second link above.
Also note the fade in the color from the back to the front in Tensorboard. On the other hand, in this image from the discussion above https://discourse-cdn-sjc2.com/standard17/uploads/plot/original/2X/e/e671a5ab96b5d911449d4607d1d2c61eced81d35.png you can see that the coloring depends on the x position instead which also offers easy visual guidance. So support for coloring depending on the x or y value would be highly useful.
The y-spacing should ideally be a parameter.
Thanks to @nicolaskruchten for guiding me here.
The text was updated successfully, but these errors were encountered: