Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matplotlib DEBUG Turn off when python DEBUG is on to debug rest of program

When I turn on DEBUG in the python logger, matplotlib prints 10,000 lines of debug code that I do not want to see. I tried:

plt.set_loglevel("info") 

as in their documentation, but still doesn't turn it off. I put the statement right after importing matplotlib, and tried it right after creating the plot with fig=plt.figure(...).

Neither works. Help? ubuntu20.04, python 3.8.5, matplotlib 3.3.3

like image 308
creeser Avatar asked Oct 31 '25 08:10

creeser


1 Answers

I found this useful for disabling matplotlib loggers:

matplotlib.pyplot.set_loglevel (level = 'warning')

If you are saving your graphs as png files, you also have to disable the PIL (PngImagePlugin) logger. PIL uses the logging libary for this

To do this:

# get the the logger with the name 'PIL'
pil_logger = logging.getLogger('PIL')  
# override the logger logging level to INFO
pil_logger.setLevel(logging.INFO)

you can also choose another logging level instead of INFO: documentation about logging levels

like image 118
Marco Spurio Cassio Avatar answered Nov 02 '25 00:11

Marco Spurio Cassio