问题描述
就像我的问题一样。我尝试了几种方法来解决这个问题,但我已经没有想法了。如何在图例中显示 12 个带有单个月份符号系统的小矩形(并仍然保留线的符号系统,或将它们移动到右上角的另一个图例框)。我对情节感兴趣,但 matplotlib 和 seaborn 也会很感激。
这是我当前的代码(没有准备数据):
trace1 = go.Bar(x=df1['Week'],y=df1['Totals'],marker = dict(color=df1['Colour']))
trace2 = go.Scatter(x=df1['Week'],y=df1['Quantity'],name='Quantity',mode = 'markers+lines',marker=dict(color='rgb(255,0)',size=7,symbol = 'diamond'))
trace3 = go.Scatter(x=df1['Week'],y=df1['InvoiceNo'],name='Invoices',yaxis='y2',255,symbol = 'hexagon'))
trace4 = go.Scatter(x=df1['Week'],y=df1['CustomerID'],name='No. of Customers',marker=dict(color='rgb(0,size=5,symbol = 'square'))
fig = make_subplots(specs=[[{"secondary_y": True}]])
fig.add_trace(trace1)
fig.add_trace(trace2,secondary_y=False)
fig.add_trace(trace3,secondary_y=True)
fig.add_trace(trace4,secondary_y=True)
fig.update_layout(xaxis=dict(tickmode='linear',tick0=0,dtick=2,tickangle=0,title = 'Week of the year'),height = 600,width = 800,title = 'Summary of annual customer activity over the weeks')
fig.update_layout(legend=dict(yanchor="top",y=0.99,xanchor="left",x=0.01),showlegend=True)
fig.update_layout(legend_title_text='Legend')
fig['layout']['yaxis'].update(title='Spend sum / bought items',range=[0,1000000],dtick=200000,autorange=False)
fig['layout']['yaxis2'].update(title='No. of clients / invoices',2000],dtick=400,autorange=False)
fig.show()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)