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 ?
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.
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 ?
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.