From ac2afc6bca56b005ac6beea5de9a0f2b65135870 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 29 Sep 2018 02:23:16 -0400 Subject: [PATCH] Improve selection of inset indicator connectors. Instead of selecting just one pair of corners, determine whether each connector is visible individually based on relative position of the bbox corners that each one connects. --- lib/matplotlib/axes/_axes.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index e63b7a75f36b..1f814ca41514 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -580,16 +580,14 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None, bboxins = pos.transformed(self.figure.transFigure) rectbbox = mtransforms.Bbox.from_bounds( *bounds).transformed(transform) - if rectbbox.x0 < bboxins.x0: - sig = 1 - else: - sig = -1 - if sig*rectbbox.y0 < sig*bboxins.y0: - connects[0].set_visible(False) - connects[3].set_visible(False) - else: - connects[1].set_visible(False) - connects[2].set_visible(False) + x0 = rectbbox.x0 < bboxins.x0 + x1 = rectbbox.x1 < bboxins.x1 + y0 = rectbbox.y0 < bboxins.y0 + y1 = rectbbox.y1 < bboxins.y1 + connects[0].set_visible(x0 ^ y0) + connects[1].set_visible(x0 == y1) + connects[2].set_visible(x1 == y0) + connects[3].set_visible(x1 ^ y1) return rectpatch, connects