 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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]: [<matplotlib.lines.Line2D at 0x7fa6e00f5e48>] In [6]: plt.ioff() In [7]: ax.plot([1, 1, 2, 1, 2, 2]) Out[7]: [<matplotlib.lines.Line2D at 0x7fa6e0063ef0>] In [8]: fig.show() In [9]:
Output

Advertisements
 