I'm trying to reuse the Line 2D object returned by plt.plot() instead of generating the plot again.
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0,50,50)
y = 2*x
a, = plt.plot(x,y)
a is Line2D object which I'm trying to reuse it below.
<matplotlib.lines.Line2D at 0x1754aaeb1c8>
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.add_line(a)
fig
However, this results in a run time error:
RuntimeError: Can not put single artist in more than one figure
I'm trying to find out how to reuse an object returned by plot function at other cells/other places. What's the correct way to use the Line2D object returned earlier to plot a graph without running all over again or using plt.plot(x,y) again?