Skip to content

Commit 4332149

Browse files
Docs added
1 parent 33ca3e8 commit 4332149

File tree

2 files changed

+91
-12
lines changed

2 files changed

+91
-12
lines changed

matplotview/__init__.py

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,71 @@
11
from matplotview._view_axes import view_wrapper
22

33
def view(axes, axes_to_view, image_interpolation="nearest"):
4+
"""
5+
Convert an axes into a view of another axes, displaying the contents of
6+
the second axes.
7+
8+
Parameters
9+
----------
10+
axes: Axes
11+
The axes to turn into a view of another axes.
12+
13+
axes_to_view: Axes
14+
The axes to display the contents of in the first axes, the 'viewed'
15+
axes.
16+
17+
image_interpolation:
18+
The image interpolation method to use when displaying scaled images
19+
from the axes being viewed. Defaults to "nearest". Supported options
20+
are 'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16',
21+
'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric',
22+
'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos',
23+
or 'none'
24+
"""
425
return view_wrapper(type(axes)).from_axes(axes, axes_to_view, image_interpolation)
526

6-
def zoom_inset_axes(axes, bounds, *, image_interpolation="nearest", transform=None, zorder=5, **kwargs):
27+
28+
def inset_zoom_axes(axes, bounds, *, image_interpolation="nearest", transform=None, zorder=5, **kwargs):
29+
"""
30+
Add a child inset Axes to an Axes, which automatically plots
31+
artists contained within the parent Axes.
32+
33+
Parameters
34+
----------
35+
axes: Axes
36+
The axes to insert a new inset zoom axes inside.
37+
38+
bounds: [x0, y0, width, height]
39+
Lower-left corner of inset Axes, and its width and height.
40+
41+
transform: `.Transform`
42+
Defaults to `ax.transAxes`, i.e. the units of *rect* are in
43+
Axes-relative coordinates.
44+
45+
zorder: number
46+
Defaults to 5 (same as `.Axes.legend`). Adjust higher or lower
47+
to change whether it is above or below data plotted on the
48+
parent Axes.
49+
50+
image_interpolation: string
51+
Supported options are 'antialiased', 'nearest', 'bilinear',
52+
'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite',
53+
'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell',
54+
'sinc', 'lanczos', or 'none'. The default value is 'nearest'. This
55+
determines the interpolation used when attempting to render a
56+
zoomed version of an image.
57+
58+
**kwargs
59+
Other keyword arguments are passed on to the child `.Axes`.
60+
61+
Returns
62+
-------
63+
ax
64+
The created `~.axes.Axes` instance.
65+
66+
Examples
67+
--------
68+
See `Axes.inset_axes` method for examples.
69+
"""
770
inset_ax = axes.inset_axes(bounds, transform, zorder, **kwargs)
871
return view(inset_ax, axes, image_interpolation)

matplotview/_view_axes.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@
55

66

77
def view_wrapper(axes_class):
8+
"""
9+
Construct a ViewAxes, which subclasses, or wraps a specific Axes subclass.
10+
A ViewAxes can be configured to display the contents of another Axes
11+
within the same Figure.
12+
13+
Parameters
14+
----------
15+
axes_class: Axes
16+
An axes type to construct a new ViewAxes wrapper class for.
17+
18+
Returns
19+
-------
20+
ViewAxes:
21+
The view axes wrapper for a given axes class, capable of display
22+
other axes contents...
23+
"""
24+
825
@docstring.interpd
926
class ViewAxesImpl(axes_class):
1027
"""
@@ -18,8 +35,7 @@ class ViewAxesImpl(axes_class):
1835
def __init__(
1936
self,
2037
axes_to_view,
21-
rect,
22-
zorder=5,
38+
*args,
2339
image_interpolation="nearest",
2440
**kwargs
2541
):
@@ -29,13 +45,11 @@ def __init__(
2945
Parameters
3046
----------
3147
axes_to_view: `~.axes.Axes`
32-
The axes to zoom in on which this axes will be nested inside.
33-
34-
rect: [left, bottom, width, height]
35-
The Axes is built in the rectangle *rect*.
48+
The axes to create a view of.
3649
37-
zorder: int
38-
An integer, the z-order of the axes. Defaults to 5.
50+
*args
51+
Additional arguments to be passed to the Axes class this
52+
ViewAxes wraps.
3953
4054
image_interpolation: string
4155
Supported options are 'antialiased', 'nearest', 'bilinear',
@@ -46,16 +60,17 @@ def __init__(
4660
attempting to render a view of an image.
4761
4862
**kwargs
49-
Other optional keyword arguments:
63+
Other optional keyword arguments supported by the Axes
64+
constructor this ViewAxes wraps:
5065
5166
%(Axes:kwdoc)s
5267
5368
Returns
5469
-------
55-
`~.axes.ZoomViewAxes`
70+
ViewAxes
5671
The new zoom view axes instance...
5772
"""
58-
super().__init__(axes_to_view.figure, rect, zorder=zorder,
73+
super().__init__(axes_to_view.figure, *args, zorder=zorder,
5974
**kwargs)
6075
self._init_vars(axes_to_view, image_interpolation)
6176

@@ -173,4 +188,5 @@ def from_axes(cls, axes, axes_to_view, image_interpolation="nearest"):
173188

174189
return ViewAxesImpl
175190

191+
176192
ViewAxes = view_wrapper(Axes)

0 commit comments

Comments
 (0)