You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
showlegend parameter of piechart should take a list as argument #4671
Piecharts can currently only show all legend entries or none. It would be useful, if users could pass a list of booleans as argument to the showlegend parameter. E.g.:
import plotly.graph_objects as go
labels = ['Oxygen','Hydrogen','Carbon_Dioxide','Nitrogen']
values = [4500, 2500, 1053, 500]
# pull is given as a fraction of the pie radius
fig = go.Figure(data=[go.Pie(labels=labels, values=values, pull=[0, 0, 0.2, 0], showlegend=[False, True, True, True])])
fig.show()
Our use case comes from the print area. Here we have three charts with the same legends side by side. To save some space on the page, the legends shouldn't be repeated over and over again. Instead, we show only a third of the legends under the first chart, then the second third of legends under the second chart, etc.
I don't have a strong preference when it comes to the implementation. Pie charts are not very common, so a simple list of booleans might be enough for us, but if you have other preferences this is fine by us. From an design perspective I would consider, that there are already other parameters (like pull) that work based on a list, so using a list seems consistent to me.
To further specify our use case: Ideally we would like to manage the legend entries for each slice of the pie as separate entities. This means it should also be possible to assign them to different legends and customize them accordingly.
changed the title [-]feat: showlegend parameter of piechart should take a list as argument[/-][+]showlegend parameter of piechart should take a list as argument[/+]on Aug 13, 2024
Activity
[-]feat: showlegend parameter of piechart should take a list as argument[/-][+]showlegend parameter of piechart should take a list as argument[/+]emilykl commentedon Sep 1, 2026
Implemented in
plotly/plotly.js#7580
#5464
#5465
and first released in plotly.py v6.5.2.