Hey Guys,
Is there anyway to get a Pie Chart to have text on the slices and also on the outside? I was reading the documentation for textposition ( enumerated or array of enumerateds : āinsideā | āoutsideā | āautoā | ānoneā )
but was not sure how to implement that if possible.
Essentially I would like to plot the label inside and the percent outside
textinfo=ālabel+percentā,textposition = āinside for labe, outside for percentā
Thanks!
1 Like
I have the same proplem, did you found the answer?
Unfortunately not my friend, if you happen to find a solution please let me know!
I compromised and changed the presentation of the data as it was too cluttered if the value was not able to be presented outside.
Hi @tehnexus and @Luidgi,
I donāt think itās possible to place the label inside the wedge and the percent outside, at least not on a single pie trace.
But, hereās a work around that might work for you. If you create a figure with two identical Pie
traces they will exactly overlap each other. So if you display the percentage on the outside of the first trace (the one behind) and the label on the inside of the second trace (the one in front) youāll get the appearance that I think you want.
For example:
from plotly.offline import iplot, init_notebook_mode
import plotly.graph_objs as go
init_notebook_mode()
labels = ['Oxygen','Hydrogen','Carbon_Dioxide','Nitrogen']
values = [4500,2500,1053,500]
common_props = dict(labels=labels,
values=values,)
trace1 = go.Pie(
**common_props,
textinfo='percent',
textposition='outside')
trace2 = go.Pie(
**common_props,
textinfo='label',
textposition='inside')
iplot([trace1, trace2], filename='basic_pie_chart')
Hope that helps!
5 Likes
Hi, Iām having the same problem.
Is there any way to achieve it with R?
Thanks!