添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I’m having problems with ordering the lengends for pie chart.
I’ve thought the order is based on how it is labeled (A, B, C, D and so on in my case.)
However, it seems like it is decided by the size of its ratio in pie chart.

In short, I want to have my right-hand side legend to have [A, B, C, D, E, F] order …

Is there any way I can configure this ?

Here is my actual pie chart and the codes are below

Thanks in advance!!

38%20PM 1140×824 37.5 KB
            dcc.Graph(
                id='sns_pie_1',
                figure={
                  "data": [
                      "values": by_sns_platform_1,
                      "labels": ['A', 'B', 'C', 'D', 'E', 'F'],
                      "domain": {"x": [0, .48]},
                      "name": "Published",
                      "hoverinfo":"label+percent+name",
                      "hole": .3,
                      "type": "pie",
                      "marker" : {"colors":color_palette_1}
              

Ah dang, this is a little frustrating when using Plotly express with a color faceting to produce different traces. I have a sequence of years in my legend that are not sorted, and I can’t sort them using trace_orders as that reorders the actual traces, breaking the sorting of my the already sorted x-axis values.

Looking at the link click through counts in this thread and this other related thread on this issue, this could be a friction point for a few people: Customizing the order of Legends