import numpy as np
import matplotlib.pyplot as plt

plt.ion()

data1 = np.random.random_sample(100)
data2 = 10 * np.random.random_sample(200)

line1, = plt.plot(data1)
line2, = plt.plot(data2)
line2.remove()
ax = plt.gca()

# See the plot scale as if line1 had not been removed.
plt.autoscale(enable=True, axis='both')

# Now try updating the axes dataLim as proposed in
# http://old.nabble.com/Removing-a-line-from-a-plot-td7249600.html
ax.dataLim.set_points(np.arra([[0., 0.], [0., 0.]]))
for line in ax.lines:
    ax.dataLim.update_from_data_xy(line.get_xydata())

# Now autoscale works as expected.
plt.autoscale(enable=True, axis='both')

