python - 将 matplotlib 转换为plotly

标签 python python-3.x pandas matplotlib plotly

我想知道是否可以将索引的名称从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/

相关文章:

python - 如何将一个小的 numpy 数组 "embed"变成一个大的 numpy 数组的预定义 block ?

python - 如何使用 python Pandas 减去行?

python - Numpy:多维数组值内的比较

python - 使用 CFFI 的缓冲协议(protocol)

python - 为什么Python中进程数大于CPU线程总数时应用程序可以运行得更快?

python-3.x - Python 3 键盘中断错误

python - 将空格分隔的整数求和为列表中的字符串

python - 在 python 中使用数据框实现函数

python - 计算由长度不等的二维索引列表给出的 DataFrame 行组的平均值

python - 检查前 n 行的值是否都大于当前行的值