gpt4 book ai didi

python - 将 matplotlib 转换为plotly

转载 作者:太空宇宙 更新时间:2023-11-03 20:41:11 24 4
gpt4 key购买 nike

我想知道是否可以将索引的名称从matplot导入到plotly中,正如我在下面尝试的那样:

Matplot 栏:

fig = plt.figure(figsize = (10, 5))
ax = fig.add_subplot(111)

pd.Series([10, 20, 30, 40, 50], index =['a', 'b', 'c', 'd', 'e']).plot.bar(ax = ax)

enter image description here

将 Matplot Bar 转换为 Plotly:

fig = plt.figure(figsize = (10, 5))
ax = fig.add_subplot(111)

pd.Series([10, 20, 30, 40, 50], index =['a', 'b', 'c', 'd', 'e']).plot.bar(ax = ax)

py.iplot_mpl(fig)

enter image description here

最佳答案

试试这个,

import plotly.plotly as py
import plotly.graph_objs as go

data = [go.Bar(
x=['a', 'b', 'c', 'd', 'e'],
y=[10, 20, 30, 40, 50]
)]

py.plot(data, filename='basic-bar')

关于python - 将 matplotlib 转换为plotly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56845502/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com