Closed
Description
I'm having a bit of an obscure issue drawing lines from one subplot (using data coordinates) to another subplot (using axes fraction coordinates). When the destination subplot is empty, the code works fine:
from matplotlib.patches import ConnectionPatch
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(8,8))
x=np.arange(0,10)
y=x**2
ax_1 = plt.subplot2grid([2,2], loc=[0,0])
plt.plot(x, y)
ax_2 = plt.subplot2grid([2,2], loc=[1,1])
#plt.plot(x, y)
ax_1.add_artist(ConnectionPatch(xyA=[5,25], xyB=[.5,1],
coordsA="data", coordsB="axes fraction",
axesA=ax_1, axesB=ax_2,
arrowstyle="-|>"))
but when the destination subplot contains a plot, the line is interpreted in data coordinates instead of the requested axes fraction coordinates:
from matplotlib.patches import ConnectionPatch
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(8,8))
x=np.arange(0,10)
y=x**2
ax_1 = plt.subplot2grid([2,2], loc=[0,0])
plt.plot(x, y)
ax_2 = plt.subplot2grid([2,2], loc=[1,1])
plt.plot(x, y)
ax_1.add_artist(ConnectionPatch(xyA=[5,25], xyB=[.5,1],
coordsA="data", coordsB="axes fraction",
axesA=ax_1, axesB=ax_2,
arrowstyle="-|>"))
Am I being silly? Is there a better way to do this? Or is it a bug?
Metadata
Metadata
Assignees
Labels
No labels