试图绘制数据帧列,但没有显示任何内容

时间:2017-07-22 16:00:35

标签: python matplotlib

我正在尝试使用以下内容绘制数据框的列:

data['close'].plot()

但没有出现。 我得到了这个答案:

<matplotlib.axes._subplots.AxesSubplot object at 0x1192fe410>

这是一个示例数据:

          date             open     high     low      close  t
0       20150101 130000  1.20965  1.20977  1.20962  1.20962  0
1       20150101 130100  1.20963  1.20968  1.20962  1.20962  0
2       20150101 130200  1.20965  1.20970  1.20961  1.20961  0
3       20150101 130400  1.20959  1.21008  1.20959  1.20983  0
4       20150101 130500  1.20988  1.20988  1.20988  1.20988  0
5       20150101 130600  1.20984  1.20984  1.20982  1.20982  0
6       20150101 130700  1.20986  1.20999  1.20986  1.20987  0
7       20150101 130800  1.20998  1.21022  1.20987  1.21008  0
8       20150101 130900  1.20996  1.20996  1.20996  1.20996  0
9       20150101 131000  1.21013  1.21019  1.20967  1.20977  0
10      20150101 131100  1.20976  1.20999  1.20976  1.20988  0
11      20150101 131200  1.20987  1.20987  1.20987  1.20987  0
12      20150101 131300  1.20997  1.21006  1.20993  1.21006  0
13      20150101 131400  1.21007  1.21007  1.21006  1.21006  0
14      20150101 131600  1.21004  1.21004  1.21004  1.21004  0
15      20150101 131800  1.21003  1.21004  1.20979  1.20979  0
16      20150101 132700  1.21003  1.21003  1.20979  1.21003  0
17      20150101 132800  1.20979  1.21003  1.20979  1.21003  0
18      20150101 132900  1.21001  1.21003  1.20999  1.21003  0
19      20150101 133100  1.21033  1.21041  1.21033  1.21033  0
20      20150101 133200  1.21028  1.21035  1.21006  1.21035  0
21      20150101 133500  1.21005  1.21006  1.21005  1.21005  0
22      20150101 133600  1.21004  1.21006  1.21004  1.21006  0
23      20150101 133700  1.20991  1.21006  1.20991  1.21004  0
24      20150101 133800  1.21003  1.21004  1.20982  1.21004  0
25      20150101 133900  1.21019  1.21034  1.21019  1.21034  0
26      20150101 134000  1.21030  1.21034  1.21030  1.21032  0
27      20150101 134100  1.21006  1.21007  1.21006  1.21007  0
28      20150101 134300  1.21003  1.21006  1.21003  1.21006  0
29      20150101 134400  1.21003  1.21007  1.21003  1.21007  0
...                 ...      ...      ...      ...      ... ..
253033  20150904 162900  1.11511  1.11515  1.11499  1.11509  0
253034  20150904 163000  1.11509  1.11511  1.11507  1.11507  0
253035  20150904 163100  1.11507  1.11530  1.11507  1.11524  0
253036  20150904 163200  1.11521  1.11546  1.11520  1.11537  0
253037  20150904 163300  1.11533  1.11533  1.11520  1.11528  0
253038  20150904 163400  1.11528  1.11528  1.11528  1.11528  0
253039  20150904 163500  1.11527  1.11527  1.11486  1.11491  0
253040  20150904 163600  1.11492  1.11517  1.11489  1.11513  0
253041  20150904 163700  1.11513  1.11513  1.11499  1.11503  0
253042  20150904 163800  1.11498  1.11502  1.11482  1.11491  0
253043  20150904 163900  1.11490  1.11491  1.11489  1.11491  0
253044  20150904 164000  1.11490  1.11491  1.11490  1.11490  0
253045  20150904 164100  1.11488  1.11488  1.11477  1.11480  0
253046  20150904 164200  1.11482  1.11483  1.11481  1.11483  0
253047  20150904 164300  1.11482  1.11484  1.11482  1.11483  0
253048  20150904 164400  1.11483  1.11484  1.11480  1.11484  0
253049  20150904 164500  1.11480  1.11502  1.11480  1.11501  0
253050  20150904 164600  1.11502  1.11506  1.11488  1.11506  0
253051  20150904 164700  1.11501  1.11501  1.11496  1.11501  0
253052  20150904 164800  1.11501  1.11510  1.11499  1.11505  0
253053  20150904 164900  1.11504  1.11520  1.11503  1.11504  0
253054  20150904 165000  1.11506  1.11513  1.11502  1.11511  0
253055  20150904 165100  1.11509  1.11509  1.11500  1.11501  0
253056  20150904 165200  1.11500  1.11510  1.11500  1.11500  0
253057  20150904 165300  1.11516  1.11516  1.11498  1.11505  0
253058  20150904 165400  1.11503  1.11503  1.11454  1.11469  0
253059  20150904 165500  1.11472  1.11472  1.11454  1.11462  0
253060  20150904 165600  1.11462  1.11487  1.11447  1.11479  0
253061  20150904 165700  1.11484  1.11506  1.11477  1.11497  0
253062  20150904 165800  1.11495  1.11497  1.11432  1.11435  0

我在osx上。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

即使我们在这里缺少上下文...... 要显示绘图,请使用plt.show()

import matplotlib.pyplot as plt
...
plt.show()

如果您使用的是Jupyter,则可能需要添加:

%matplotlib inline