1

I am using spyder 4 in anaconda, everything was fine, I could plot graph in the "plot window" with plt.show()

However, I got the error as following since yesterday and I have now idea why.

'Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.' I have checked the file "matplotlibrc" and it should be using "tkagg" as default backend. And I am pretty sure the tkinder is installed.

import numpy as np
import matplotlib
#matplotlib.use('tkagg')

import tkinter
import matplotlib.pyplot as plt
import pandas as pd


x = np.linspace(0, 100, 11)
y = np.linspace(0, 100, 11)
plt.plot(x, y)
plt.show()
# fig.savefig(show.png)

The backend error The pops up window and hang

I look on the internet and some said to add the line ' matplotlib.use('tkagg') ' . If I run the code then a small window pops up and just hang there with no response.

Anyone could point me to a right direction. All I want to do is to show the plot in the "plot window"

Thanks in advance.

Kit1995
  • 11
  • 1
  • 2
  • Does this help? [“UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.” when plotting figure with pyplot on Pycharm](https://stackoverflow.com/questions/56656777/userwarning-matplotlib-is-currently-using-agg-which-is-a-non-gui-backend-so) – Abdul Aziz Barkat Jan 20 '21 at 06:08
  • Thanks, but I have already installed the tkinter because when I run "tkinter._test()", a tkinter window pops up and showing the version is 8.6 – Kit1995 Jan 20 '21 at 06:18
  • 1
    It is solved by uninstall and then reinstall the matplotlib, I think it might due to some version conflict. Thanks. – Kit1995 Jan 20 '21 at 06:40

0 Answers0