Python 具体来说,如何绘制饼图?
我如何在“fig”中的子批次“pie1”,使其位于“fig”位置。我就是这样做的,但没有成功:Python 具体来说,如何绘制饼图?,python,pandas,plotly,subplot,Python,Pandas,Plotly,Subplot,我如何在“fig”中的子批次“pie1”,使其位于“fig”位置。我就是这样做的,但没有成功: 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 ip
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')
运行脚本时,我得到了一个奇怪的结果:
如您所见,它只显示标题。不确定我做错了什么。(不过我可以在查特工作室看到图表)如果你发现了,我很想知道。在我的研究中,我还没有找到一种方法来做到这一点。我找到了matplotlib.pyplot的解决方法,但在我的研究中,Plot.ly无法制作饼图。@Polkaguy6000您知道如何在plotly中对条形图进行子绘图吗?如果您发现我非常想知道,可能会重复。在我的研究中,我还没有找到一种方法来做到这一点。我已经找到了matplotlib.pyplot的解决方法,但在我的研究中,Plot.ly无法制作饼图。@Polkaguy6000您知道如何在plotly中对条形图进行子绘图吗?可能是