Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

Interactive Plotting with Python Matplotlib via Command Line



To get interactive plots, we need to activate the figure. Using plt.ioff() and plt.ion(), we can perform interactive actions with a plot.

Open Ipython shell and enter the following commands on the shell.

Example

In [1]: %matplotlib auto
Using matplotlib backend: GTK3Agg

In [2]: import matplotlib.pyplot as

In [3]: fig, ax = plt.subplots() # Diagram will pop up. Let’s interact.

In [4]: ln, = ax.plot(range(5))  # Drawing a line

In [5]: ln.set_color("orange")   # Changing drawn line to orange

In [6]: plt.ioff() # Stopped interaction

In [7]: ln.set_color("red")
# Since we have stopped the interaction in the last step

In [8]: plt.ion() # Started interaction

Output

Updated on: 2021-06-03T09:44:34+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements