plotly.js
plotly.js copied to clipboard
[Feature Requested]: Sunburst direction
Similarly to the Rotation or starting point, a direction
argument (with values "clockwise"
(by default) and "counterclockwise"
) would be desirable.
Please note that a sort (boolean) parameter was added recently to Sunburst trace. By setting that parameter to false, you can order the data at your end, in the direction desired.
Thanks for the info! I understand this does not solve the issue completely, I think; although it may allow ordering the categories in reverse, the change does not propagate to the animations for opening/closing the plot levels.
In relation to this issue, I tried to add the line 'sort': False in the trace of a Plotly sunburst chart. However, it does not seem to work. The order of labels in the chart was not the order in the dataframe. The order seemed to be changed by Plotly.
Is there any ETA for this issue ?
Did you try to build your figure with graph_objects
and not plotly express
?
It seems that Plotly Express applies an unwanted sort on path
columns when using px.sunburst
.
@xeladsn, I am using the Plotly Express generated meta data but creating the sunburst by using that meta data in graph_objects. Based on this link:
https://stackoverflow.com/questions/61241172/plotly-how-to-create-sunburst-subplot-using-graph-objects/61245407#61245407
Any idea, how to get the sort disabled ?
@usser123 I would recommend using graphs_objects and not Plotly Express to create your sunburst trace if you want to keep the data order. Here is a basic example why on the image below (data order is ['a', 'c', 'b', 'd']) :
Plotly Express appears to reorder the data for the column named cat
, even if sort=False
have been applied to the figure traces.
As this odd behavior does not relate to the current topic let's create a new issue if you confirm that sort=False
works well for your use case if you use graph_objects.
@xeladsn, I am using Plotly Express generated labels and parents in my graph_objects chart. It is quite laborious to specify labels and parents in graph_objects directly. So the issue does exist for me.
The issue for this already exists in github: https://github.com/plotly/plotly.js/pull/5164
The issue you mentions (https://github.com/plotly/plotly.js/pull/5164) was related to the order for the sunburst trace. It is already fixed and merged. The re-ordering that appears for your use case is related to Plotly Express only, and not to the sunburst trace sort
attribute (see image attached in my last message).
I think you can't disable that custom ordering when using Plotly Express. This is an issue, but should be addressed separately as it seems to be unrelated to the sunburst trace sort
attribute.
Ok, I did not realize that re-ordering and sort are different things. In that case, yes this is a separate issue.
Really interested in getting the sorting to work properly on this.
Is there any advance there?
This is extremely annoying that the default displaying order is counterclockwise ... as most people on earth are used to ... clockwise as the default functioning for about everything (starting with clocks)
This is definitively a very different topic than "sorting" The easily visible issue is that when sorting is enabled, data are sorted counterclockwise ... instead of the cross-industry standard which is ... clockwise !
There is no "advance" to be reported here, no. Things advance when people step up to work on them and no one has done so to date. Expressing your annoyance at the status quo does not particularly encourage anyone to do so either.
I'll note that it kind of seems like the issue being reported here is with Plotly Express' behaviour, not Plotly.js' ... this might be a better fit for a Plotly.py issue: https://github.com/plotly/plotly.py/
There is no "advance" to be reported here, no. Things advance when people step up to work on them and no one has done so to date. Expressing your annoyance at the status quo does not particularly encourage anyone to do so either.
No annoyance ;-) I'm new to Plotly and find it super cool. Just want to know the status because I had spent a lot of time on understanding what was my problem ... until I finally made it here.
Happy to help solve the problem if I can as I have a real need there.
'll note that it kind of seems like the issue being reported here is with Plotly Express' behaviour, not Plotly.js' ... this might be a better fit for a Plotly.py issue: plotly/plotly.py
I'll have a look, thanks
OK. Here is where Plotly Express converts between the input data frame and the structure which go.Sunburst
requires. Any changes to how things are sorted would need to be made here. https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/plotly/express/_core.py#L1543
I'll note that it kind of seems like the issue being reported here is with Plotly Express' behaviour, not Plotly.js' ... this might be a better fit for a Plotly.py issue: https://github.com/plotly/plotly.py/
Actually I opened this issue because I was working with the R plotly package; I understood this behavior affected the whole plotly.js library, but maybe I got confused with the R package interface... Is that so?