-2
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.

how to solve it

Sajjad Aemmi
  • 2,120
  • 3
  • 13
  • 25
UA-AUX
  • 9
  • 1
  • 1
  • Can you provide more details about what you are trying to do, perhaps a snippet of the code you are using and a complete stack trace of the error? Hard to get the exact solution with only the error text. Look at [this](https://stackoverflow.com/q/37365357/5028532) if you're using jupyter notebooks. – razdi Sep 05 '19 at 06:43
  • Does this answer your question? ["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) – Jérôme Jan 02 '23 at 14:39

1 Answers1

2

You need to set a different backend if you want to use plt.show(). The Agg backend can only write plots to files, not show an interactive output. You set the backend globally by setting the backend field in your matplotlibrc file (https://matplotlib.org/users/customizing.html#the-matplotlibrc-file).

You can also set the backend from within your program. Just have a look at the page linked above.

Jankas
  • 21
  • 2