plotly.js icon indicating copy to clipboard operation
plotly.js copied to clipboard

[Feature Requested]: Sunburst direction

Open DaniMori opened this issue 4 years ago • 10 comments

Similarly to the Rotation or starting point, a direction argument (with values "clockwise" (by default) and "counterclockwise") would be desirable.

DaniMori avatar Dec 12 '20 19:12 DaniMori

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.

sunburst sort

thierryVergult avatar Dec 28 '20 08:12 thierryVergult

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.

DaniMori avatar May 11 '21 14:05 DaniMori

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 ?

usser123 avatar Jul 13 '21 03:07 usser123

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 avatar Jul 13 '21 18:07 xeladsn

@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 avatar Jul 14 '21 01:07 usser123

@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']) :

sunburst_order

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 avatar Jul 14 '21 16:07 xeladsn

@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

usser123 avatar Jul 19 '21 04:07 usser123

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.

xeladsn avatar Jul 19 '21 10:07 xeladsn

Ok, I did not realize that re-ordering and sort are different things. In that case, yes this is a separate issue.

usser123 avatar Jul 20 '21 05:07 usser123

Really interested in getting the sorting to work properly on this.

nickriches avatar Jun 26 '22 08:06 nickriches

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 !

Skrattoune avatar Mar 14 '23 18:03 Skrattoune

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.

nicolaskruchten avatar Mar 14 '23 18:03 nicolaskruchten

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/

nicolaskruchten avatar Mar 14 '23 19:03 nicolaskruchten

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

Skrattoune avatar Mar 15 '23 07:03 Skrattoune

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

nicolaskruchten avatar Mar 15 '23 13:03 nicolaskruchten

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?

DaniMori avatar Mar 20 '23 14:03 DaniMori