子图饼图在图上不起作用?

时间:2019-03-04 20:40:30

标签: python pandas plotly subplot

我可以对条形图而不是对饼形图进行子图绘制。我不确定自己在做什么错。

                    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'))
 #it works for Bar   
                    bar1=go.Bar(x=con_pivot1.index,y=con_pivot1.Payment)
                    data=[pie1]
                    layout=go.Layout(title='Collection Update',barmode='stack')
                    fig.append_trace(bar1, 1, 1)
                    fig=go.Figure(data=data,layout=layout)
                    pyp.plot(fig,filename='Plot')
    #it doesn't work for PIEs
     pie1=go.Pie(labels=con_pivot1.index,values=con_pivot1.ExpectedPayment,domain=dict(x=[0.5,1.0]),name='Test',hoverinfo='label+percent+name')
                fig.append_trace(pie1, 1, 1)

这时我得到错误:为plotly.graph_objs.Pie类型的对象指定了无效的属性:'xaxis'

0 个答案:

没有答案