第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > python plotly 平均值折线图_如何使用Plotly带有折线图的堆积条形图?

python plotly 平均值折线图_如何使用Plotly带有折线图的堆积条形图?

时间:2021-04-04 10:24:56

相关推荐

python plotly 平均值折线图_如何使用Plotly带有折线图的堆积条形图?

我想使用plotly和iPython创建一个带有线条图的条形图,如上例所示。另一方面,我希望条形图是一个水平堆积条形图,如下例中使用plotly和iPython。我该怎么做呢?

y_saving_yes = [1, 2, 4, 6, 7, 7]

y_saving_no = [10, 10, 10, 10, 10, 10]

y_net_worth = [93453, 81666, 69889, 78381, 141395, 92969]

x_saving = ['Premium', 'Spot Shadow', 'Slow Motion', 'Highlight Music','Extra Text', 'Top Play']

x_net_worth = ['Premium', 'Spot Shadow', 'Slow Motion', 'Highlight Music','Extra Text', 'Top Play']

trace1 = Bar(

x=y_saving,

y=x_saving,

marker=Marker(

color='rgba(50, 171, 96, 0.6)',

line=Line(

color='rgba(50, 171, 96, 1.0)',

width=1,

),

),

name='Highlight Properties',

orientation='h',

)

trace2 = Bar(

x=y_saving,

y=x_saving,

marker=Marker(

color='rgba(50, 171, 96, 0.6)',

line=Line(

color='rgba(50, 171, 96, 1.0)',

width=1,

),

),

name='Highlight Properties',

orientation='h',

)

data = Data([trace1, trace2])

layout = Layout(barmode='stack')

fig1 = Figure(data=data, layout=layout)

trace3 = Scatter(

x=y_net_worth,

y=x_net_worth,

mode='lines+markers',

line=Line(

color='rgb(128, 0, 128)',

),

name='Highlight Views',

)

fig = tools.make_subplots(rows=1, cols=2, specs=[[{}, {}]], shared_xaxes=True,

shared_yaxes=False, vertical_spacing=0.001)

fig.append_trace(trace1, 1, 1)

fig.append_trace(trace3, 1, 2)

fig['layout'].update(layout)

py.iplot(fig, filename='oecd-networth-saving-bar-line')

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。