How to change backends in Matplotlib?


We can override the backend value using atplotlib.rcParams['backend'] variable.

Steps

  • Using get_backend() method, return the name of the current backend, i.e., default name.

  • Now override the backend name.

  • Using get_backend() method, return the name of the current backend, i.e., updated name.

Example

import matplotlib
print("Before, Backend used by matplotlib is: ", matplotlib.get_backend())
matplotlib.rcParams['backend'] = 'TkAgg'
print("After, Backend used by matplotlib is: ", matplotlib.get_backend())

Output

Before, Backend used by matplotlib is: GTK3Agg
After, Backend used by matplotlib is: TkAgg
Enter number of bars: 5

Updated on: 16-Mar-2021

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements