0

I have an virtual environment, which already has matplotlib packages installed. When I run the code below I get the error:

The result

This is the script code:

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()
hellow
  • 10,920
  • 6
  • 47
  • 69
  • 2
    Please, do not post code or errors as images! https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors – hellow Aug 28 '18 at 06:40

1 Answers1

0

I hope this will help.

If you have already installed matplotlib using pip on your virtual environment, you can just type the following:

$ cd ~/.matplotlib
$ nano matplotlibrc

And then, write backend: TkAgg in there.

For more information, go to this.

Using one line:

echo "backend : TkAgg" > ~/.matplotlib/matplotlibrc or echo "backend : Agg" > ~/.matplotlib/matplotlibrc
Ishara Madhawa
  • 3,357
  • 4
  • 23
  • 39