【发布时间】:2019-08-05 04:02:15
【问题描述】:
我正在尝试像在 pandas 数据帧上正常绘图一样使用袖扣
df:
group people value
1 5 100
2 2 90
1 10 80
2 20 40
1 7 100
import pandas as pd
import matplotlib.pyplot as plt
import cufflinks as cf
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)
cf.go_offline()
fig, (ax1, ax2) = plt.subplots(1,2,figsize = (10, 20))
df['value'].iplot(ax = ax1)
df['people'].iplot(ax = ax2)
它给了我一些奇怪的结果,空图,我也不能将它用于辅助轴
ax = df.iplot('value')
df.iplot('people',secondary_y=True, ax=ax)
它给我错误,“KeyError: True”
当我只使用简单的熊猫情节时,它们都可以正常工作。如何使用 pandas 和袖扣运行辅助轴?
【问题讨论】:
标签: python pandas matplotlib plotly