diff --git a/lib/mpl_toolkits/axes_grid1/inset_locator.py b/lib/mpl_toolkits/axes_grid1/inset_locator.py index eecee9d7fab2..4d8d56057586 100644 --- a/lib/mpl_toolkits/axes_grid1/inset_locator.py +++ b/lib/mpl_toolkits/axes_grid1/inset_locator.py @@ -11,6 +11,7 @@ from matplotlib.path import Path from matplotlib.transforms import Bbox, BboxTransformTo from matplotlib.transforms import IdentityTransform, TransformedBbox +import matplotlib.cbook as cbook from . import axes_size as Size from .parasite_axes import HostAxes @@ -312,7 +313,10 @@ def __init__(self, bbox1, bbox2, loc1, loc2=None, **kwargs): raise ValueError("transform should not be set") kwargs["transform"] = IdentityTransform() - Patch.__init__(self, fill=False, **kwargs) + _alias_map = {'color': ['c'], 'facecolor': ['fc']} + kwargs = cbook.normalize_kwargs(kwargs, _alias_map) + fill = ('color' in kwargs) or ('facecolor' in kwargs) + Patch.__init__(self, fill=fill, **kwargs) self.bbox1 = bbox1 self.bbox2 = bbox2 self.loc1 = loc1 @@ -330,10 +334,10 @@ def __init__(self, bbox1, bbox2, loc1a, loc2a, loc1b, loc2b, **kwargs): """ Connect two bboxes with a quadrilateral. - The quadrilateral is specified by two lines that start and end at corners - of the bboxes. The four sides of the quadrilateral are defined by the two - lines given, the line between the two corners specified in *bbox1* and the - line between the two corners specified in *bbox2*. + The quadrilateral is specified by two lines that start and end at + corners of the bboxes. The four sides of the quadrilateral are defined + by the two lines given, the line between the two corners specified in + *bbox1* and the line between the two corners specified in *bbox2*. Parameters ---------- diff --git a/lib/mpl_toolkits/tests/baseline_images/test_axes_grid1/BboxConnectorPatch.pdf b/lib/mpl_toolkits/tests/baseline_images/test_axes_grid1/BboxConnectorPatch.pdf new file mode 100644 index 000000000000..42dcb00dc312 Binary files /dev/null and b/lib/mpl_toolkits/tests/baseline_images/test_axes_grid1/BboxConnectorPatch.pdf differ diff --git a/lib/mpl_toolkits/tests/baseline_images/test_axes_grid1/BboxConnectorPatch.png b/lib/mpl_toolkits/tests/baseline_images/test_axes_grid1/BboxConnectorPatch.png new file mode 100644 index 000000000000..c1b3949271ec Binary files /dev/null and b/lib/mpl_toolkits/tests/baseline_images/test_axes_grid1/BboxConnectorPatch.png differ diff --git a/lib/mpl_toolkits/tests/baseline_images/test_axes_grid1/BboxConnectorPatch.svg b/lib/mpl_toolkits/tests/baseline_images/test_axes_grid1/BboxConnectorPatch.svg new file mode 100644 index 000000000000..640edf6ee4a3 --- /dev/null +++ b/lib/mpl_toolkits/tests/baseline_images/test_axes_grid1/BboxConnectorPatch.svg @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/mpl_toolkits/tests/test_axes_grid1.py b/lib/mpl_toolkits/tests/test_axes_grid1.py index 9ae16faf270f..43044eb772b4 100644 --- a/lib/mpl_toolkits/tests/test_axes_grid1.py +++ b/lib/mpl_toolkits/tests/test_axes_grid1.py @@ -7,10 +7,13 @@ import matplotlib.pyplot as plt from matplotlib.testing.decorators import image_comparison +from matplotlib.transforms import Bbox, TransformedBbox,\ + blended_transform_factory from mpl_toolkits.axes_grid1 import host_subplot from mpl_toolkits.axes_grid1 import make_axes_locatable from mpl_toolkits.axes_grid1 import AxesGrid -from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes, mark_inset +from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes,\ + mark_inset, BboxConnectorPatch from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar from matplotlib.colors import LogNorm @@ -19,6 +22,21 @@ import numpy as np +@image_comparison(baseline_images=['BboxConnectorPatch'], style='default', + remove_text=True) +def test_BboxConnectorPatch(): + # Simple image test for a BboxConnectorPatch + fig, ax = plt.subplots() + trans1 = blended_transform_factory(ax.transData, ax.transData) + bbox1 = Bbox([[0.1, 0.1], [0.4, 0.4]]) + bbox1 = TransformedBbox(bbox1, trans1) + bbox2 = Bbox([[0.5, 0.5], [0.9, 0.9]]) + bbox2 = TransformedBbox(bbox2, trans1) + p = BboxConnectorPatch(bbox1, bbox2, + loc1a=3, loc2a=2, loc1b=4, loc2b=3, ec="r", fc="b") + ax.add_patch(p) + + @image_comparison(baseline_images=['divider_append_axes']) def test_divider_append_axes(): @@ -68,16 +86,16 @@ def test_twin_axes_empty_and_removed(): matplotlib.rcParams.update({"font.size": 8}) matplotlib.rcParams.update({"xtick.labelsize": 8}) matplotlib.rcParams.update({"ytick.labelsize": 8}) - generators = [ "twinx", "twiny", "twin" ] - modifiers = [ "", "host invisible", "twin removed", "twin invisible", - "twin removed\nhost invisible" ] + generators = ["twinx", "twiny", "twin"] + modifiers = ["", "host invisible", "twin removed", "twin invisible", + "twin removed\nhost invisible"] # Unmodified host subplot at the beginning for reference h = host_subplot(len(modifiers)+1, len(generators), 2) h.text(0.5, 0.5, "host_subplot", horizontalalignment="center", - verticalalignment="center") + verticalalignment="center") # Host subplots with various modifications (twin*, visibility) applied for i, (mod, gen) in enumerate(product(modifiers, generators), - len(generators)+1): + len(generators)+1): h = host_subplot(len(modifiers)+1, len(generators), i) t = getattr(h, gen)() if "twin invisible" in mod: @@ -87,7 +105,7 @@ def test_twin_axes_empty_and_removed(): if "host invisible" in mod: h.axis[:].set_visible(False) h.text(0.5, 0.5, gen + ("\n" + mod if mod else ""), - horizontalalignment="center", verticalalignment="center") + horizontalalignment="center", verticalalignment="center") plt.subplots_adjust(wspace=0.5, hspace=1) diff --git a/pytest.ini b/pytest.ini index d9132bfa6002..ac3fc00b67bc 100644 --- a/pytest.ini +++ b/pytest.ini @@ -77,7 +77,6 @@ pep8ignore = mpl_toolkits/axes_grid1/axes_rgb.py E231 E501 mpl_toolkits/axes_grid1/axes_size.py E225 E261 E302 E303 E501 mpl_toolkits/axes_grid1/colorbar.py E225 E231 E261 E262 E302 E303 E501 E701 - mpl_toolkits/axes_grid1/inset_locator.py E501 mpl_toolkits/axes_grid1/mpl_axes.py E302 E303 E501 E502 mpl_toolkits/axes_grid1/parasite_axes.py E225 E231 E302 E303 E402 E501 E502 mpl_toolkits/axisartist/__init__.py E501 @@ -97,7 +96,6 @@ pep8ignore = mpl_toolkits/mplot3d/axes3d.py E203 E225 E231 E271 E303 E402 E501 E502 E701 mpl_toolkits/mplot3d/axis3d.py E201 E202 E203 E222 E231 E302 E303 E501 E502 mpl_toolkits/mplot3d/proj3d.py E231 E302 E303 - mpl_toolkits/tests/test_axes_grid1.py E201 E202 mpl_toolkits/tests/test_mplot3d.py E231 E302 mpl_toolkits/__init__.py E261 mpl_toolkits/exceltools.py E201 E202 E225 E228 E302 E303 E501 E701