Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

plotly pie chart in pie chart

import plotly.graph_objs as go

labels = ['Oxygen','Hydrogen','Carbon_Dioxide','Nitrogen']
outer_values = [4500,2500,500]
inner_values = [500, 1000, 2000, 1000,
                 500, 1000, 1000,
                 200, 300]

common_props = dict(labels=labels,
                    values=values,)

trace1 = go.Pie(
    hole=0.5,
    sort=False,
    direction='clockwise',
    domain={'x': [0.15, 0.85], 'y': [0.15, 0.85]},
    values=inner_values,
    textinfo='label',
    textposition='inside',
    marker={'line': {'color': 'white', 'width': 1}}
)

trace2 = go.Pie(
    hole=0.7,
    sort=False,
    direction='clockwise',
    values=outer_values,
    labels=labels,
    textinfo='label',
    textposition='outside',
    marker={'colors': ['green', 'red', 'blue'],
            'line': {'color': 'white', 'width': 1}}
)

fig = go.FigureWidget(data=[trace1, trace2])
fig
Source by community.plotly.com #
 
PREVIOUS NEXT
Tagged: #plotly #pie #chart #pie #chart
ADD COMMENT
Topic
Name
6+7 =