我知道熊猫支持辅助Y轴,但我很好奇,如果有人知道一种方法将三维Y轴放在图上......目前我用numpy + pyplot实现了这个...但是对于大数据集它很慢.
这是在同一图表上绘制不同单位的不同测量值,以便于比较(例如相对湿度/温度/和电导率)
所以真的很好奇,如果有人知道如果pandas没有太多的工作,这是否可行.
[编辑]我怀疑有没有办法做到这一点(没有太多开销)但是我希望被证明是错误的,这可能是matplotlib的限制......
我有一个包含 3 列的数据框,如下所示:
import pandas as pd
y = [2005, 2005, 2005, 2015, 2015, 2015, 2030, 2030, 2030]
n = ['A', 'B', 'C', 'A', 'B', 'C', 'A', 'B', 'C']
w = [80, 65, 88, 65, 60, 70, 60, 55, 65]
df = pd.DataFrame({'year': y, 'name': n, 'weight': w})
year name weight
0 2005 A 80
1 2005 B 65
2 2005 C 88
3 2015 A 65
4 2015 B 60
5 2015 C 70
6 2030 A 60
7 …Run Code Online (Sandbox Code Playgroud) 我有以下数据框
Date A B
0 2017-05-31 17453139 5.865738
1 2017-06-30 17425164 5.272728
2 2017-07-31 17480789 4.843094
Run Code Online (Sandbox Code Playgroud)
当我运行这个:
df.plot(x='Date', y='A')
df.B.plot(secondary_y=True)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
> appdata\local\programs\python\python36\lib\site-packages\pandas\plotting\_timeseries.py
> in format_dateaxis(subplot, freq, index)
> 335 TimeSeries_TimedeltaFormatter())
> 336 else:
> --> 337 raise TypeError('index type not supported')
> 338
> 339 pylab.draw_if_interactive()
>
> TypeError: index type not supported
Run Code Online (Sandbox Code Playgroud)