Để có được các ô tương tác, chúng ta cần kích hoạt hình vẽ. Sử dụng plt.ioff () và plt.ion () , chúng tôi có thể thực hiện các hành động tương tác với một âm mưu.
Mở Ipython shell và nhập các lệnh sau vào shell.
Ví dụ
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 Đầu ra