Skip to main content
 首页 » 编程设计

python之Enthought + PyCharm之无法再显示绘图

2025年05月04日14jpfss

我在 Mac OS X PyCharm 上将 Enthought 设置为解释器:

~/Library/Enthought/Canopy_64bit/User 

但是,它不显示来自 matplotlib 的任何图。

import pandas as pd 
from numpy import * 
import matplotlib.pyplot as plt 
ts = pd.Series(random.randn(1000), index=pd.date_range('1/1/2000', periods=1000)) 
ts = ts.cumsum() 
ts.plot() 

这只是给我 Out[124]: <matplotlib.axes.AxesSubplot at 0x10dd29f90> .它不显示情节,也不做任何其他事情。没有错误,什么都没有。

请您参考如下方法:

您缺少对将显示绘图项的 show() 函数的调用。

import pandas as pd 
from numpy import * 
import matplotlib.pyplot as plt 
ts = pd.Series(random.randn(1000), index=pd.date_range('1/1/2000', periods=1000)) 
ts = ts.cumsum() 
ts.plot() 
plt.show() 

PyCharm 很可能没有在与 matplotlib 的交互模式下配置。