8000 DOC: change name, add to api list... · matplotlib/matplotlib@8a7a7f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8a7a7f7

Browse files
committed
DOC: change name, add to api list...
1 parent 5baf6ac commit 8a7a7f7

File tree

4 files changed

+69
-47
lines changed

4 files changed

+69
-47
lines changed

doc/api/axes_api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ Text and Annotations
165165
Axes.text
166166
Axes.table
167167
Axes.arrow
168+
Axes.inset_axes_from_lbwh
169+
Axes.indicate_inset_lbwh
170+
Axes.indicate_inset_zoom
168171

169172

170173
Fields

examples/subplots_axes_and_figures/zoom_inset_axes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def get_demo_image():
3131
origin="lower")
3232

3333
# inset axes....
34-
axins = ax.inset_axes_rect([0.5, 0.5, 0.47, 0.47])
34+
axins = ax.inset_axes_from_lbwh([0.5, 0.5, 0.47, 0.47])
3535
axins.imshow(Z2, extent=extent, interpolation="nearest",
3636
origin="lower")
3737
# sub region of the original image
@@ -41,7 +41,7 @@ def get_demo_image():
4141
axins.set_xticklabels('')
4242
axins.set_yticklabels('')
4343

44-
ax.zoom_inset_indicator(axins)
44+
ax.indicate_inset_zoom(axins)
4545

4646
plt.show()
4747

@@ -55,6 +55,6 @@ def get_demo_image():
5555
# The use of the following functions and methods is shown in this example:
5656

5757
import matplotlib
58-
matplotlib.axes.Axes.inset_axes_rect
59-
matplotlib.axes.Axes.zoom_inset_indicator
58+
matplotlib.axes.Axes.inset_axes_from_lbwh
59+
matplotlib.axes.Axes.indicate_inset_zoom
6060
matplotlib.axes.Axes.imshow

lib/matplotlib/axes/_axes.py

Lines changed: 59 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ def _plot_args_replacer(args, data):
7777
"supported due to ambiguity of arguments.\nUse "
7878
"multiple plotting calls instead.")
7979

80+
8081
def _make_inset_locator(rect, trans, parent):
8182
"""
82-
Helper function to locate inset axes, used in `.Axes.inset_axes`.
83+
Helper function to locate inset axes, used in `.Axes.inset_axes_from_lbwh`.
8384
8485
A locator gets used in `Axes.set_aspect` to override the default
8586
locations... It is a function that takes an axes object and
@@ -410,15 +411,20 @@ def legend(self, *args, **kwargs):
410411
def _remove_legend(self, legend):
411412
self.legend_ = None
412413

413-
def inset_axes_rect(self, rect, *, transform=None, zorder=5,
414+
def inset_axes_from_lbwh(self, lbwh, *, transform=None, zorder=5,
414415
**kwargs):
415416
"""
416417
Add a child inset axes to this existing axes.
417418
419+
Warnings
420+
--------
421+
422+
This method is experimental as of 3.0, and the API may change.
423+
418424
Parameters
419425
----------
420426
421-
rect : [x0, y0, width, height]
427+
lbwh : [x0, y0, width, height]
422428
Lower-left corner of inset axes, and its width and height.
423429
424430
transform : `.Transform`
@@ -430,15 +436,15 @@ def inset_axes_rect(self, rect, *, transform=None, zorder=5,
430436
to change whether it is above or below data plotted on the
431437
parent axes.
432438
433-
Other Parameters
434-
----------------
439+
**kwargs
435440
436-
Other *kwargs* are passed on to the `axes.Axes` child axes.
441+
Other *kwargs* are passed on to the `axes.Axes` child axes.
437442 F438
438443
Returns
439444
-------
440445
441-
New `.axes.Axes` instance.
446+
Axes
447+
The created `.axes.Axes` instance.
442448
443449
Examples
444450
--------
@@ -448,16 +454,17 @@ def inset_axes_rect(self, rect, *, transform=None, zorder=5,
448454
449455
fig, ax = plt.suplots()
450456
ax.plot(range(10))
451-
axin1 = ax.inset_axes([0.8, 0.1, 0.15, 0.15])
452-
axin2 = ax.inset_axes([5, 7, 2.3, 2.3], transform=ax.transData)
457+
axin1 = ax.inset_axes_from_lbwh([0.8, 0.1, 0.15, 0.15])
458+
axin2 = ax.inset_axes_from_lbwh(
459+
[5, 7, 2.3, 2.3], transform=ax.transData)
453460
454461
"""
455462
if transform is None:
456463
transform = self.transAxes
457-
label = kwargs.pop('label', 'inset_axes')
464+
label = kwargs.pop('label', 'inset_axes_from_lbwh')
458465

459466
# This puts the rectangle into figure-relative coordinates.
460-
inset_locator = _make_inset_locator(rect, transform, self)
467+
inset_locator = _make_inset_locator(lbwh, transform, self)
461468
bb = inset_locator(None, None)
462469

463470
inset_ax = Axes(self.figure, bb.bounds, zorder=zorder,
@@ -471,18 +478,24 @@ def inset_axes_rect(self, rect, *, transform=None, zorder=5,
471478

472479
return inset_ax
473480

474-
def inset_indicator(self, rect, inset_ax=None, *, transform=None,
481+
def indicate_inset_lbwh(self, lbwh, inset_ax=None, *, transform=None,
475482
facecolor='none', edgecolor='0.5', alpha=0.5,
476483
zorder=4.99, **kwargs):
477484
"""
478485
Add an inset indicator to the axes. This is a rectangle on the plot
479-
at the position indicated by *rect* that optionally has lines that
480-
connect the rectangle to an inset axes (`.Axes.inset_axes`).
486+
at the position indicated by *lbwh* that optionally has lines that
487+
connect the rectangle to an inset axes (`.Axes.inset_axes_from_lbwh`).
488+
489+
Warnings
490+
--------
491+
492+
This method is experimental as of 3.0, and the API may change.
493+
481494
482495
Parameters
483496
----------
484497
485-
rect : [x0, y0, width, height]
498+
lbwh : [x0, y0, width, height]
486499
Lower-left corner of rectangle to be marked, and its width
487500
and height.
488501
@@ -507,21 +520,21 @@ def inset_indicator(self, rect, inset_ax=None, *, transform=None,
507520
Transparency of the rectangle and connector lines. Default is 0.5.
508521
509522
zorder : number
510-
drawing order of the rectangle and connector lines. Default is 4.99
523+
Drawing order of the rectangle and connector lines. Default is 4.99
511524
(just below the default level of inset axes).
512525
513-
Other Parameters
514-
----------------
515-
516-
Other *kwargs* are passed on to the rectangle patch.
526+
**kwargs
527+
Other *kwargs* are passed on to the rectangle patch.
517528
518529
Returns
519530
-------
520531
521-
rectangle_patch, connector_lines :
522-
`.Patches.Rectangle`, (four-tuple `.Patches.ConnectionPatch`) one
523-
for each of four connector lines. Two are set with visibility to
524-
*False*, but the user can set the visibility to True if the
532+
rectangle_patch: `.Patches.Rectangle`
533+
Rectangle artist.
534+
535+
connector_lines: 4-tuple of `.Patches.ConnectionPatch`
536+
One for each of four connector lines. Two are set with visibility
537+
to *False*, but the user can set the visibility to True if the
525538
automatic choice is not deemed correct.
526539
527540
"""
@@ -532,10 +545,10 @@ def inset_indicator(self, rect, inset_ax=None, *, transform=None,
532545

533546
if transform is None:
534547
transform = self.transData
535-
label = kwargs.pop('label', 'inset_indicator')
548+
label = kwargs.pop('label', 'indicate_inset_lbwh')
536549

537-
xy = (rect[0], rect[1])
538-
rectpatch = mpatches.Rectangle(xy, rect[2], rect[3],
550+
xy = (lbwh[0], lbwh[1])
551+
rectpatch = mpatches.Rectangle(xy, lbwh[2], lbwh[3],
539552
facecolor=facecolor, edgecolor=edgecolor, alpha=alpha,
540553
zorder=zorder, label=label, transform=transform, **kwargs)
541554
self.add_patch(rectpatch)
@@ -546,8 +559,8 @@ def inset_indicator(self, rect, inset_ax=None, *, transform=None,
546559
pos = inset_ax.get_position() # this is in fig-fraction.
547560
coordsA = 'axes fraction'
548561
connects = []
549-
xr = [rect[0], rect[0]+rect[2]]
550-
yr = [rect[1], rect[1]+rect[3]]
562+
xr = [lbwh[0], lbwh[0]+lbwh[2]]
563+
yr = [lbwh[1], lbwh[1]+lbwh[3]]
551564
for xc in range(2):
552565
for yc in range(2):
553566
xyA = (xc, yc)
@@ -561,7 +574,7 @@ def inset_indicator(self, rect, inset_ax=None, *, transform=None,
561574
pos = inset_ax.get_position()
562575
bboxins = pos.transformed(self.figure.transFigure)
563576
rectbbox = mtransforms.Bbox.from_bounds(
564-
*rect).transformed(transform)
577+
*lbwh).transformed(transform)
565578
if rectbbox.x0 < bboxins.x0:
566579
sig = 1
567580
else:
@@ -575,12 +588,17 @@ def inset_indicator(self, rect, inset_ax=None, *, transform=None,
575588

576589
return rectpatch, connects
577590

578-
def zoom_inset_indicator(self, inset_ax, **kwargs):
591+
def indicate_inset_zoom(self, inset_ax, **kwargs):
579592
"""
580593
Add an inset indicator rectangle to the axes based on the axis
581594
limits for an *inset_ax* and draw connectors between *inset_ax*
582595
and the rectangle.
583596
597+
Warnings
598+
--------
599+
600+
This method is experimental as of 3.0, and the API may change.
601+
584602
Parameters
585603
----------
586604
@@ -589,26 +607,27 @@ def zoom_inset_indicator(self, inset_ax, **kwargs):
589607
drawn connecting the indicator box to the inset axes on corners
590608
chosen so as to not overlap with the indicator box.
591609
592-
Other Parameters
593-
----------------
594-
595-
Other *kwargs* are passed on to `.Axes.inset_rectangle`
610+
**kwargs
611+
Other *kwargs* are passed on to `.Axes.inset_rectangle`
596612
597613
Returns
598614
-------
599615
600-
rectangle_patch, connector_lines :
601-
`.Patches.Rectangle`, (four-tuple `.Patches.ConnectionPatch`) one
602-
for each of four connector lines. Two are set with visibility to
603-
*False*, but the user can set the visibility to True if the
616+
rectangle_patch: `.Patches.Rectangle`
617+
Rectangle artist.
618+
619+
connector_lines: 4-tuple of `.Patches.ConnectionPatch`
620+
One for each of four connector lines. Two are set with visibility
621+
to *False*, but the user can set the visibility to True if the
604622
automatic choice is not deemed correct.
605623
606624
"""
607625

608626
xlim = inset_ax.get_xlim()
609627
ylim = inset_ax.get_ylim()
610628
rect = [xlim[0], ylim[0], xlim[1] - xlim[0], ylim[1] - ylim[0]]
611-
rectpatch, connects = self.inset_indicator(rect, inset_ax, **kwargs)
629+
rectpatch, connects = self.indicate_inset_lbwh(
630+
rect, inset_ax, **kwargs)
612631

613632
return rectpatch, connects
614633

lib/matplotlib/tests/test_axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5743,15 +5743,15 @@ def test_zoom_inset():
57435743
ax.apply_aspect()
57445744
# we need to apply_aspect to make the drawing below work.
57455745

5746-
# Make the inset_axes... Position axes co-ordinates...
5747-
axin1 = ax.inset_axes_rect([0.7, 0.7, 0.35, 0.35])
5746+
# Make the inset_axes_from_lbwh... Position axes co-ordinates...
5747+
axin1 = ax.inset_axes_from_lbwh([0.7, 0.7, 0.35, 0.35])
57485748
# redraw the data in the inset axes...
57495749
axin1.pcolormesh(x, y, z)
57505750
axin1.set_xlim([1.5, 2.15])
57515751
axin1.set_ylim([2, 2.5])
57525752
axin1.set_aspect(ax.get_aspect())
57535753

5754-
rec, connectors = ax.zoom_inset_indicator(axin1)
5754+
rec, connectors = ax.indicate_inset_zoom(axin1)
57555755
fig.canvas.draw()
57565756
xx = np.array([[1.5, 2.],
57575757
[2.15, 2.5]])

0 commit comments

Comments
 (0)
0