I'm getting odd behaviour in Matplotlib when I try to reuse a Line2D artist from one figure in another: in the second figure the artist is offset.
Am I doing something wrong or is this a bug? And if so is there a quick way to avert it?
I've boiled the problem down to the following code:
import matplotlib.pyplot as pyplt
import numpy as np
xs=np.arange(10)
ys=np.arange(10)
line=pyplt.Line2D(xs,ys,color="red",linewidth=1)
print "IN THIS FIRST FIGURE, line LOOKS JUST FINE"
figure1 = pyplt.figure()
axes1 = figure1.add_subplot(111)
axes1.add_artist(line)
pyplt.show()
pyplt.close('all')
print "BUT WHEN I REUSE line IN ANOTHER FIGURE, IT IS OFFSET"
figure2 = pyplt.figure()
axes2 = figure2.add_subplot(111)
axes2.add_artist(line)
pyplt.show()
pyplt.close('all')
Image at https://i.stack.imgur.com/ZERTP.jpg but I lack the reputation to post it.