密谋如何对饼图进行子图绘制?

时间:2019-03-04 14:42:39

标签: python pandas plotly subplot

如何在“ fig”中子图“ pie1”,使其位于“第一个”位置。这是我的做法,但无法解决:

import pandas as pd
import numpy as np
import seaborn as sns
import plotly.offline as pyp
import plotly.graph_objs as go
from plotly import tools
import plotly.plotly as py
from plotly.offline import iplot,init_notebook_mode
from IPython.core.display import HTML
import plotly.io

df1=pd.read_excel('file.xlsx',sheet_name='sheet1',index=False)
con_pivot=pd.pivot_table(con,index='Category',values=('Payment'),aggfunc='sum',margins=True,margins_name='Total')

fig = tools.make_subplots(rows=2, cols=2, subplot_titles=('The first','3','2','4'))

pie1=go.Pie(labels=con_pivot.index,values=con_pivot.values,domain=dict(x=[0.5,1.0]),name='Test',hoverinfo='label+percent+name',)
layout = go.Layout(title="Test XXXX",)
data=[pie1]
fig = go.Figure(data=data, layout=layout)
pyp.plot(fig, filename='simple-pie-subplot')

运行脚本时,我得到一个奇怪的结果: enter image description here

如您所见,

仅显示标题。不知道我在做什么错。(虽然我可以在Chart Studio中查看图表)

0 个答案:

没有答案