Matplotlib warning [error?] message
Zahraa Fadhil
zahraazirjawi at gmail.com
Sun Feb 18 15:17:19 EST 2024
On Sunday, February 18, 2024 at 10:48:29 PM UTC+3, Leif Svalgaard wrote:
> The latest[?] version of Matplotlib cannot show a figure. I get the
> annoying error message: "Matplotlib is currently using agg, which is a
> non-GUI backend, so cannot show the figure"
> I'm using Spyder python 3.11 on Windows 11.
> What to do?
>
> --
> Leif Svalgaard
>
I have the same problem
try this
1) add this line first
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
2) delete this line from your cod.....matplotlib.use('Agg')
3) save the result into png file
plt.savefig('D:\data\mygraph.png')
another solution
https://www.w3schools.com/python/trypandas.asp?filename=demo_ml_dtree4
import sys
import matplotlib
matplotlib.use('Agg')
....
import matplotlib.pyplot as plt
....
#Two lines to make compiler able to draw:
plt.savefig(sys.stdout.buffer)
sys.stdout.flush()
More information about the Python-list
mailing list