Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Programmatically Stop Interaction for specific Figure in Jupyter notebook
To programmatically stop interaction for specific figures in Jupyter notebook, we can use plt.off() to stop any interaction after that.
Execute the following commnads sequentially −
- %matplotlib auto
- import matplotlib.pyplot as plt
- plt.rcParams["figure.figsize"] = [7.50, 3.50]
- plt.rcParams["figure.autolayout"] = True
- Create a figure and a set of subplots.
- Plot the line on the axis (From step 5).
- Turn off the interaction.
- To display the figure, use show() method.
Example
In [1]: %matplotlib auto Using matplotlib backend: Qt5Agg In [2]: import matplotlib.pyplot as plt In [3]: plt.rcParams["figure.figsize"] = [7.50, 3.50] ...: plt.rcParams["figure.autolayout"] = True In [4]: fig, ax = plt.subplots() In [5]: ax.plot([2, 4, 7, 5, 4, 1]) Out[5]: [] In [6]: plt.ioff() In [7]: ax.plot([1, 1, 2, 1, 2, 2]) Out[7]: [ ] In [8]: fig.show() In [9]:
Output

Advertisements
