Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7c9c01b

Browse files
committed
Some more path construction simplifications.
1 parent f9fbe96 commit 7c9c01b

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

examples/animation/animated_histogram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
# in the ``verts`` array to keep the codes aligned with the vertices.
4646
nverts = nrects * (1 + 3 + 1)
4747
verts = np.zeros((nverts, 2))
48-
codes = np.ones(nverts, int) * path.Path.LINETO
48+
codes = np.full(nverts, path.Path.LINETO)
4949
codes[0::5] = path.Path.MOVETO
5050
codes[4::5] = path.Path.CLOSEPOLY
5151
verts[0::5, 0] = left

lib/mpl_toolkits/axes_grid1/inset_locator.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -235,25 +235,14 @@ def connect_bbox(bbox1, bbox2, loc1, loc2=None):
235235
corner of *bbox2*.
236236
"""
237237
if isinstance(bbox1, Rectangle):
238-
transform = bbox1.get_transform()
239-
bbox1 = Bbox.from_bounds(0, 0, 1, 1)
240-
bbox1 = TransformedBbox(bbox1, transform)
241-
238+
bbox1 = TransformedBbox(Bbox.unit(), bbox1.get_transform())
242239
if isinstance(bbox2, Rectangle):
243-
transform = bbox2.get_transform()
244-
bbox2 = Bbox.from_bounds(0, 0, 1, 1)
245-
bbox2 = TransformedBbox(bbox2, transform)
246-
240+
bbox2 = TransformedBbox(Bbox.unit(), bbox2.get_transform())
247241
if loc2 is None:
248242
loc2 = loc1
249-
250243
x1, y1 = BboxConnector.get_bbox_edge_pos(bbox1, loc1)
251244
x2, y2 = BboxConnector.get_bbox_edge_pos(bbox2, loc2)
252-
253-
verts = [[x1, y1], [x2, y2]]
254-
codes = [Path.MOVETO, Path.LINETO]
255-
256-
return Path(verts, codes)
245+
return Path([[x1, y1], [x2, y2]])
257246

258247
@docstring.dedent_interpd
259248
def __init__(self, bbox1, bbox2, loc1, loc2=None, **kwargs):

0 commit comments

Comments
 (0)