【发布时间】:2017-03-03 22:18:41
【问题描述】:
我有两个 Pandas DataFrame,我试图在同一个图表上绘制。
- all_data:需要将其绘制为折线图
- points_of_interest:需要将其绘制为同一图表中的散点图
这是我用来绘制它们的代码:
axes = all_data[ASK_PRICE].plot(figsize=(16, 12))
points_of_interest[ASK_PRICE].plot(figsize=(16, 12), ax = axes, kind='scatter')
pylab.show()
当我运行这段代码时,它会说:
>>> points_of_interest[ASK_PRICE].plot(figsize=(16, 12), ax = axes, kind='scatter')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/shubham/.local/lib/python2.7/site-packages/pandas/tools/plotting.py", line 3599, in __call__
**kwds)
File "/home/shubham/.local/lib/python2.7/site-packages/pandas/tools/plotting.py", line 2673, in plot_series
**kwds)
File "/home/shubham/.local/lib/python2.7/site-packages/pandas/tools/plotting.py", line 2430, in _plot
% kind)
ValueError: plot kind 'scatter' can only be used for data frames
我已经确认这两个数据框都是“DataFrame”类型。我错过了什么?
【问题讨论】:
标签: python pandas numpy matplotlib plot