plotly柱状直方图参照对比,Python

import plotly as py
import plotly.graph_objs as go

if __name__ == '__main__':
    year = [2018, 2019, 2020]

    trace_1 = go.Bar(
        x=year,
        y=[1, 2, 3],
        name="甲"
    )

    trace_2 = go.Bar(
        x=year,
        y=[4, 5, 6],
        name="乙"
    )

    trace_3 = go.Bar(
        x=year,
        y=[7, 8, 9],
        name="丙"
    )

    trace = [trace_1, trace_2, trace_3]

    layout = go.Layout(
        title='对比'
    )
    figure = go.Figure(data=trace, layout=layout)
    py.offline.plot(figure, filename='fig.html')

如图:

发布了1029 篇原创文章 · 获赞 987 · 访问量 336万+

猜你喜欢

转载自blog.csdn.net/zhangphil/article/details/103618726