Matplotlib – python – cla()

# draw - erase - replot

import matplotlib.pyplot as plt
import numpy as np
import pdb
plt.ion()

x = np.linspace(0, 2*3.14, 100)
y = np.sin(x)
pts = []

fig, ax = plt.subplots()
pt1, = ax.plot(x, y)
pt2, = ax.plot(x, y + 2)
pts = [pt1, pt2]
#pnt.figure.canvas.mpl_connect('button_press_event', onPress)
#pnt.figure.canvas.mpl_connect('motion_notify_event', onPress)
input("Tap Enter: ")
plt.cla()
input("Tap Enter: ")
x = pts[0].get_xdata()
y = pts[0].get_ydata()
ax.plot(x, y)
x = pts[1].get_xdata()
y = pts[1].get_ydata()
ax.plot(x, y)
input('Tap Enter: ')
plt.show()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s