我试图通过 plotly 在 python 中绘制两个不同的图表。我有两个图,一个图由合并图(折线图和条形图)组成,如下所示,
另一个是条形图,如下所示,
我想用这两个组合图表显示一个图表并显示相同的图表。我已经试过这plotly通过make_subplots但我不能够正确地达到的结果。下面是创建这两个图表的代码,
Line_Bar_chart 代码:
import plotly.graph_objects as go
from plotly.offline import iplot
trace1 = go.Scatter(
mode='lines+markers',
x = df['Days'],
y = df['Perc_Cases'],
name="Percentage Cases",
marker_color='crimson'
)
trace2 = go.Bar(
x = df['Days'],
y = df['Count_Cases'],
name="Absolute_cases",
yaxis='y2',
marker_color ='green',
marker_line_width=1.5,
marker_line_color='rgb(8,48,107)',
opacity=0.5
)
data = [trace1, trace2]
layout = go.Layout(
title_text='States_Name',
yaxis=dict(
range = [0, 100],
side = 'right'
),
yaxis2=dict(
overlaying='y',
anchor='y3',
)
)
fig = go.Figure(data=data, layout=layout) …Run Code Online (Sandbox Code Playgroud)