导入matplolib.pyplot时出错

时间:2018-08-28 02:10:43

标签: python opencv matplotlib

我有一个虚拟环境,已经安装了matplotlib软件包。 当我运行下面的代码时,出现错误:

The result

这是脚本代码:

import cv2 as c
from matplotlib import pyplot as plt

img = c.imread('ava.png',0)

hist, binst = np.histogram(img.flatten(),256,[0,256])
cdf = hist.cumsum()
cdf_normalized = cdf * hist.max() / cdf.max()

plt.plot(cdf_normalized,color = 'b')

plt.hist(img.flatten(),256,[0,256], color = 'r')
plt.xlim([0,256])
plt.legend(('cdf','histogram'), loc = 'upper left')
plt.show()

1 个答案:

答案 0 :(得分:0)

我希望这会有所帮助。

如果您已经在虚拟环境中使用pip安装了matplotlib,则只需键入以下内容:

25
50
75
100
200
300

然后,在其中写入$ cd ~/.matplotlib $ nano matplotlibrc

有关更多信息,请转到this

使用一行:

backend: TkAgg
相关问题