-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ConnectionPatch "axis fraction" failure when axesB contains a plot #2377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The arrow looks like it's pointing to (0.5, 1) in both cases. What happens if you change it to [5, 90] in the second case? If that works, then it looks like you're still in data coordinates, and that's a bug. |
I showed it pointing to [.5,1] for both cases to show that the only difference between the two was commenting out the axis 2 plot command. In the first plot, it points to the 'axis fraction' interpretation of [.5,1], in the second it points to the 'data' coordinate interpretation. Here's a plot with the coordinates [5,90]: Which is pretty undoubtedly in data coordinates! An ugly workaround for now has been to generate an additional 'dummy' axis collocated with the original, but without any data in it. You can use 'axis fraction' coordinates on that axis no problem. |
@leejjoon - you're probably best suited to answer this one. Any ideas? |
This is a bug. The fix is simple and you may apply this by yourself (I will soon commit the fix). Otherwise, here is a workaround although not that elegant. class MyConnectionPatch(ConnectionPatch):
def get_path_in_displaycoord2(self):
dpi_cor = self.get_dpi_cor()
x, y = self.xy1
posA = self._get_xy(x, y, self.coords1, self.axesA)
x, y = self.xy2
posB = self._get_xy(x, y, self.coords2, self.axesB)
_path = self.get_connectionstyle()(posA, posB,
patchA=self.patchA,
patchB=self.patchB,
shrinkA=self.shrinkA * dpi_cor,
shrinkB=self.shrinkB * dpi_cor
)
_path, fillable = self.get_arrowstyle()(_path,
self.get_mutation_scale(),
self.get_linewidth() * dpi_cor,
self.get_mutation_aspect()
)
return _path, fillable
ax_1.add_artist(MyConnectionPatch(xyA=[5,25], xyB=[.5,1],
coordsA="data", coordsB="axes fraction",
axesA=ax_1, axesB=ax_2,
arrowstyle="-|>"))
```python |
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:
but when the destination subplot contains a plot, the line is interpreted in data coordinates instead of the requested axes fraction coordinates:
Am I being silly? Is there a better way to do this? Or is it a bug?
The text was updated successfully, but these errors were encountered: