Skip to content

Re-instate BboxConnectorPatch fill #8075

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/mpl_toolkits/axes_grid1/inset_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
----------
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 25 additions & 7 deletions lib/mpl_toolkits/tests/test_axes_grid1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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():

Expand Down Expand Up @@ -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:
Expand All @@ -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)


Expand Down
2 changes: 0 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down