how to prevent matplotlib to be shown in popup window

Question:

I use matplotlib in my lib to display legend on a ipyleaflet map. In my CD/CI tests I run several checks on this legend (values displayed, colors etc…). My problem is when it’s run on my local computer, matplotlib open a legend popup windows that stops the execution of the tests.

Is it possible to force matplotlib to remain non-interactive when I run my pytest session ?

Asked By: Pierrick Rambaud

||

Answers:

You can change the matplotlib backend to a non graphical one by calling matplotlib.use('Agg') at the beginning of your scripts. This will prevent matplotlib from opening windows.

Answered By: manu190466
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.