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


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

Updated on: 08-May-2021

262 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements