How do I configure the behavior of the Qt4Agg backend in Matplotlib?

MatplotlibServer Side ProgrammingProgramming

To configure the behaviour of the backend, we can use matplotlib.rcParams['backend'] with a new backend name.

Steps

  • Use get_backend() method to get the backend name.

  • Override the existing backend name using matplotlib.rcParams.

  • Use get_backend() method to get the configured backend name.

Example

import matplotlib
backend = matplotlib.get_backend()
print("The current backend name is: ", backend)
matplotlib.rcParams['backend'] = 'TkAgg'
backend = matplotlib.get_backend()
print("Configured backend name is: ", backend)

Output

The current backend name is: GTK3Agg
Configured backend name is: TkAgg
raja
Published on 08-May-2021 09:26:32
Advertisements