matplotlib.inset#
The inset module defines the InsetIndicator class, which draws the rectangle andconnectors required forAxes.indicate_inset andAxes.indicate_inset_zoom.
- classmatplotlib.inset.InsetIndicator(bounds=None,inset_ax=None,zorder=None,**kwargs)[source]#
Bases:
ArtistAn artist to highlight an area of interest.
An inset indicator is a rectangle on the plot at the position indicated bybounds that optionally has lines that connect the rectangle to an insetAxes (
Axes.inset_axes).Added in version 3.10.
- Parameters:
- bounds[x0, y0, width, height], optional
Lower-left corner of rectangle to be marked, and its widthand height. If not set, the bounds will be calculated from thedata limits of inset_ax, which must be supplied.
- inset_ax
Axes, optional An optional inset Axes to draw connecting lines to. Two lines aredrawn connecting the indicator box to the inset Axes on cornerschosen so as to not overlap with the indicator box.
- zorderfloat, default: 4.99
Drawing order of the rectangle and connector lines. The default,4.99, is just below the default level of inset Axes.
- **kwargs
Other keyword arguments are passed on to the
Rectanglepatch.
- propertyconnectors#
- 4-tuple of
patches.ConnectionPatchor None The four connector lines connecting to (lower_left, upper_left,lower_right upper_right) corners ofinset_ax. Two lines areset with visibility toFalse, but the user can set thevisibility to True if the automatic choice is not deemed correct.
- 4-tuple of
- draw(renderer)[source]#
Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visiblereturns False).- Parameters:
- renderer
RendererBasesubclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- set(*,agg_filter=<UNSET>,alpha=<UNSET>,animated=<UNSET>,clip_box=<UNSET>,clip_on=<UNSET>,clip_path=<UNSET>,color=<UNSET>,edgecolor=<UNSET>,gid=<UNSET>,in_layout=<UNSET>,label=<UNSET>,linestyle=<UNSET>,linewidth=<UNSET>,mouseover=<UNSET>,path_effects=<UNSET>,picker=<UNSET>,rasterized=<UNSET>,sketch_params=<UNSET>,snap=<UNSET>,transform=<UNSET>,url=<UNSET>,visible=<UNSET>,zorder=<UNSET>)[source]#
Set multiple properties at once.
a.set(a=A,b=B,c=C)
is equivalent to
a.set_a(A)a.set_b(B)a.set_c(C)
In addition to the full property names, aliases are also supported, e.g.
set(lw=2)is equivalent toset(linewidth=2), but it is an errorto pass both simultaneously.The order of the individual setter calls matches the order of parametersin
set(). However, most properties do not depend on each other sothat order is rarely relevant.Supported properties are
Property
Description
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image
unknown
bool
BboxBaseor Nonebool
Patch or (Path, Transform) or None
color or None
str
bool
object
{'-', '--', '-.', ':', '', ...} or (offset, on-off-seq)
float or None
bool
list of
AbstractPathEffectNone or bool or float or callable
bool
(scale: float, length: float, randomness: float)
bool or None
str
bool
float
- set_alpha(alpha)[source]#
Set the alpha value used for blending - not supported on all backends.
- Parameters:
- alphafloat or None
alpha must be within the 0-1 range, inclusive.
- set_color(c)[source]#
Set the edgecolor of the rectangle and the connectors, and thefacecolor for the rectangle.
- Parameters:
- set_edgecolor(color)[source]#
Set the edge color of the rectangle and the connectors.
- Parameters:
- colorcolor or None
- set_linestyle(ls)[source]#
Set the linestyle of the rectangle and the connectors.
- Parameters:
- ls{'-', '--', '-.', ':', '', ...} or (offset, on-off-seq)
Possible values:
A string:
linestyle
description
'-'or'solid'solid line
'--'or'dashed'dashed line
'-.'or'dashdot'dash-dotted line
':'or'dotted'dotted line
''or'none'(discouraged:'None','')draw nothing
A tuple describing the start position and lengths of dashes and spaces:
(offset, onoffseq)
where
offset is a float specifying the offset (in points); i.e. how muchis the dash pattern shifted.
onoffseq is a sequence of on and off ink in points. There can bearbitrary many pairs of on and off values.
Example: The tuple
(0,(10,5,1,5))means that the pattern startsat the beginning of the line. It draws a 10 point long dash,then a 5 point long space, then a 1 point long dash, followed by a 5 pointlong space, and then the pattern repeats.
For examples seeLinestyles.
- set_linewidth(w)[source]#
Set the linewidth in points of the rectangle and the connectors.
- Parameters:
- wfloat or None
- zorder=4.99#