我有以下代码来自:How to plot pie charts as subplots with custom size with Plotly in Python
import plotly
import plotly.offline as py
import plotly.graph_objs as go
py.init_notebook_mode(connected=True)
labels = ['Oxygen','Hydrogen','Carbon_Dioxide','Nitrogen']
values = [4500,2500,1053,500]
domains = [
{'x': [0.0, 0.33], 'y': [0.0, 0.50]},
{'x': [0.33, 0.66], 'y': [0.0, 0.50]},
{'x': [0.66, 1], 'y': [0.0, 0.50]},
{'x': [0.0, 0.33], 'y': [0.50, 1]},
{'x': [0.33, 0.66], 'y': [0.50, 1]},
{'x': [0.66, 1], 'y': [0.50, 1]},
]
traces = []
valueslist = []
for domain in domains:
trace = go.Pie(labels = labels,
values = values,
domain = domain)
traces.append(trace)
layout = go.Layout(height = 600,
width = 600,
autosize = False,
title = 'Main title')
fig = go.Figure(data = traces, layout = layout)
py.iplot(fig, show_link = False, image='png')
我试图用每个图表的不同值和不同标题一次绘制6个饼图。我应该如何添加这些额外的列表?假设我要添加以下列表:
values1 = [5, 6, 1, 2]
values2 = [1, 4, 5, 6]
values3 = [2, 6, 2, 4]
values4 = [1, 5, 3, 7]
values5 = [25, 51, 33, 47]
#with following titles:
title = 'title0'
title1 = 'title1'
title2 = 'title2'
title3 = 'title3'
title4 = 'title4'
title5 = 'title5'