[Matplotlib-users] ConnectionPatch axesA has to be the "latest" axes
tcaswell at gmail.com
Sun Aug 30 23:53:49 CEST 2015
Sorry for the late response.
The mailing list is now at matplotlib-users at python.org
In your second case the issue is that axes are drawn one at a time so in
that case the left axes with the line is drawn, then then right axes is
drawn which overlays the line. If you do `ax22.set_zorder(-1)` that
example will render correctly. This is a limitation of the compositing
draw scheme that we use with the Agg.
In the other two examples the issue is the check in
is called as part of the draw logic of the ConnectionPatch. This checks
that the starting point of the connection patch is with in the confines of
the axes which it belongs to. However, in your case 1 and 4 you have
added the artist to the Axes in which the _end_ belongs so the starting
point will never fall within they axes the artist belongs to, and hence
will never draw.
The two things that need to be true for this to work as expected:
- the Axes which the correction patch is added to needs to have a higher
zorder than the other axes (or be added later, the z-order sort is stable
to falls back to the order in which the elements were added to break ties)
- the connection patch must start in the Axes it belongs to.
It would probably be better if `ConnectionPatch` was a child of the Figure
instead of the Axes.
On Thu, Aug 20, 2015 at 11:55 AM Oliver <oliver.willekens at gmail.com> wrote:
> It would seem the `axesA` keyword always has to be the "latest" axes. If
> not, the connector does not get added to the figure.
> Minimal, complete and verifiable example:
> from matplotlib.patches import ConnectionPatch
> import matplotlib.pyplot as plt
> import matplotlib as mpl
> import platform
> xya = (.5,.5)
> xyb = (.6,.7)
> # shows nothing
> f1, (ax11, ax12) = plt.subplots(1,2, sharey=False)
> con1 = ConnectionPatch(xyA=xya, xyB=xyb , coordsA='data', coordsB='data',
> axesA=ax12, axesB=ax11)
> # shows clipped line
> f2, (ax21, ax22) = plt.subplots(1,2, sharey=False)
> con2 = ConnectionPatch(xyA=xyb, xyB=xya , coordsA='data', coordsB='data',
> axesA=ax21, axesB=ax22)
> # shows desired result
> f3, (ax31, ax32) = plt.subplots(1,2, sharey=False)
> con3 = ConnectionPatch(xyA=xya, xyB=xyb , coordsA='data', coordsB='data',
> axesA=ax32, axesB=ax31)
> # shows nothing
> f4, (ax41, ax42) = plt.subplots(1,2, sharey=False)
> con4 = ConnectionPatch(xyA=xyb, xyB=xya , coordsA='data', coordsB='data',
> axesA=ax41, axesB=ax42)
> While reference to clipping is made in the user guide, the seemingly
> forced choice of `axesA` had me stumped for quite some time. While I
> understand that the choice of the axes to add the connector is important to
> avoid overlap (in other words, on which axes one should call the
> `add_artist` method), it seems unimportant whether xyA or xyB are
> referenced in ax1 or ax2.
> To clarify: I was expecting example 4 above to show a similar line as
> example 3.
> Matplotlib-users mailing list
> Matplotlib-users at lists.sourceforge.net
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Matplotlib-users