平常我經常打開ipython窗口作圖,很方便,但是有時候會遇到這種情況;
In [1]: import pandas as pd
In [2]: import numpy as np
In [5]: df = pd.DataFrame(np.random.randn(10, 5),index=pd.date_range('20160201',periods=10),columns=list('ABCDE'))
In [6]: df
Out[6]:
A B C D E
2016-02-01 -0.474407 -0.919093 0.566946 -1.725423 1.263585
2016-02-02 0.847403 1.128915 1.836239 0.501051 0.271312
2016-02-03 0.156778 -0.183229 -1.493735 0.194212 -1.007523
2016-02-04 -0.469546 0.872922 0.820555 1.054698 -0.311815
2016-02-05 1.366505 0.779324 -0.332189 0.353083 1.248325
2016-02-06 0.013398 1.306481 -1.157446 -1.062542 -0.289071
2016-02-07 -0.026255 0.125846 0.143432 1.517510 -1.501634
2016-02-08 -0.056168 -1.052461 -0.346445 0.610397 0.682563
2016-02-09 0.823687 0.915865 -1.222315 0.885136 -0.125496
2016-02-10 0.431686 2.091849 0.169380 1.518855 -0.156325
In [9]: df.plot()
Out[9]: <matplotlib.axes._subplots.AxesSubplot at 0x25eff189128>
很坑有沒有,遇到這種情況咋辦呢?
這樣:
In [11]: import matplotlib.pyplot as plt
In [13]: plt.figure()
In [14]: df.plot()
In [15]: plt.show()
然後,就可以看到圖像了。。