| [ Web Proxy ] |
| Viewing: https://matplotlib.org/devdocs/api/_as_gen/matplotlib.patches.Patch.html | [Back] [Original] |
Bases: Artist
A patch is a 2D artist with a face color and an edge color.
If any of edgecolor, facecolor, linewidth, or antialiased are None, they default to their rc params setting.
The following kwarg properties are supported
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 |
|
|
bool or None |
|
|
|
|
bool |
|
Patch or (Path, Transform) or None |
|
color or None |
|
color or None |
|
color or None |
|
bool |
|
{'nonzero', 'evenodd'} |
|
str |
|
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} |
|
unknown |
|
color or 'edge' or None |
|
bool |
|
|
|
object |
|
float or None |
|
bool |
|
list of |
|
None or bool or float or callable |
|
bool |
|
(scale: float, length: float, randomness: float) |
|
bool or None |
|
str |
|
bool |
|
float |
Test whether the mouse event occurred in the patch.
MouseEventWhere the user clicked.
Additional margin on the patch in target coordinates of
Patch.get_transform. See Path.contains_point for further
details.
If None, the default value depends on the state of the object:
If Artist.get_picker is a number, the default
is that value. This is so that picking works as expected.
Otherwise if the edge color has a non-zero alpha, the default is half of the linewidth. This is so that all the colored pixels are "in" the patch.
Finally, if the edge has 0 alpha, the default is 0. This is so that patches without a stroked edge do not have points outside of the filled region report as "in" due to an invisible edge.
Return whether the given point is inside the patch.
The point (x, y) to check, in target coordinates of
.Patch.get_transform(). These are display coordinates for patches
that are added to a figure or Axes.
Additional margin on the patch in target coordinates of
Patch.get_transform. See Path.contains_point for further
details.
If None, the default value depends on the state of the object:
If Artist.get_picker is a number, the default
is that value. This is so that picking works as expected.
Otherwise if the edge color has a non-zero alpha, the default is half of the linewidth. This is so that all the colored pixels are "in" the patch.
Finally, if the edge has 0 alpha, the default is 0. This is so that patches without a stroked edge do not have points outside of the filled region report as "in" due to an invisible edge.
Notes
The proper use of this method depends on the transform of the patch. Isolated patches do not have a transform. In this case, the patch creation coordinates and the point coordinates match. The following example checks that the center of a circle is within the circle
>>> center = 0, 0
>>> c = Circle(center, radius=1)
>>> c.contains_point(center)
True
The convention of checking against the transformed patch stems from the fact that this method is predominantly used to check if display coordinates (e.g. from mouse events) are within the patch. If you want to do the above check with data coordinates, you have to properly transform them first:
>>> center = 0, 0
>>> c = Circle(center, radius=3)
>>> plt.gca().add_patch(c)
>>> transformed_interior_point = c.get_data_transform().transform((0, 2))
>>> c.contains_point(transformed_interior_point)
True
Return whether the given points are inside the patch.
The points to check, in target coordinates of
self.get_transform(). These are display coordinates for patches
that are added to a figure or Axes. Columns contain x and y values.
Additional margin on the patch in target coordinates of
Patch.get_transform. See Path.contains_point for further
details.
If None, the default value depends on the state of the object:
If Artist.get_picker is a number, the default
is that value. This is so that picking works as expected.
Otherwise if the edge color has a non-zero alpha, the default is half of the linewidth. This is so that all the colored pixels are "in" the patch.
Finally, if the edge has 0 alpha, the default is 0. This is so that patches without a stroked edge do not have points outside of the filled region report as "in" due to an invisible edge.
Notes
The proper use of this method depends on the transform of the patch.
See the notes on Patch.contains_point.
Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (Artist.get_visible
returns False).
RendererBase subclass.Notes
This method is overridden in the Artist subclasses.
Return whether the patch is filled.
Alias for get_antialiased.
Return the Transform mapping data coordinates to
physical coordinates.
Alias for get_edgecolor.
Return the edge gap color.
Added in version 3.11.
See also set_edgegapcolor.
Alias for get_facecolor.
Alias for get_linestyle.
Alias for get_linewidth.
Return the Transform instance mapping patch coordinates
to data coordinates.
For example, one may define a patch of a circle which represents a radius of 5 by providing coordinates for a unit circle, and a transform which scales the coordinates (the patch coordinate) by 5.
Return a copy of the vertices used in this patch.
If the patch contains Bzier curves, the curves will be interpolated by
line segments. To access the curves as curves, use get_path.
Get the artist's bounding box in display space, ignoring clipping.
The bounding box's width and height are non-negative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call
savefig or draw_without_rendering to have
Matplotlib compute the rendered size.
RendererBase, optionalRenderer used to draw the figure (i.e. fig.canvas.get_renderer()).
See also
Artist.get_tightbboxGet the artist bounding box, taking clipping into account.
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 to set(linewidth=2), but it is an error
to pass both simultaneously.
The order of the individual setter calls matches the order of parameters
in set(). However, most properties do not depend on each other so
that 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
bool or None
CapStyleor {'butt', 'projecting', 'round'}
BboxBaseor Nonebool
Patch or (Path, Transform) or None
color or None
color or None
color or None
bool
{'nonzero', 'evenodd'}
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
color or 'edge' or None
bool
JoinStyleor {'miter', 'round', 'bevel'}object
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
Alias for set_antialiased.
Set the alpha value used for blending - not supported on all backends.
alpha must be within the 0-1 range, inclusive.
Set the CapStyle.
The default capstyle is 'round' for FancyArrowPatch and 'butt' for
all other patches.
CapStyle or {'butt', 'projecting', 'round'}Set both the edgecolor and the facecolor.
See also
Patch.set_facecolor, Patch.set_edgecolorFor setting the edge or face color individually.
Alias for set_edgecolor.
Set a color to fill the gaps in the dashed edge style.
Added in version 3.11.
Note
Striped edges are created by drawing two interleaved dashed lines. There can be overlaps between those two, which may result in artifacts when using transparency.
This functionality is experimental and may change.
The color with which to fill the gaps. If None, the gaps are unfilled.
Alias for set_facecolor.
Set the rule for filling a shape.
See Fill rule demo.
'nonzero' for the non-zero winding rule (the default), or 'evenodd' for the even-odd rule
References
Set the hatching pattern.
hatch can be one of:
/ - diagonal hatching
\ - back diagonal
| - vertical
- - horizontal
+ - crossed
x - crossed diagonal
o - small circle
O - large circle
. - dots
* - stars
Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.
In regular (non-raw) Python strings, backslashes must be doubled:
'\\\\' and r'\\' are both a double back-diagonal hatch.
Set the JoinStyle.
The default joinstyle is 'round' for FancyArrowPatch and 'miter' for
all other patches.
JoinStyle or {'miter', 'round', 'bevel'}Set the patch linestyle.
A named line style (e.g. "dashed", or short "--") or a dash tuple
(offset, (on_off_seq)).
For a full reference see Linestyles.
Alias for set_linestyle.
Alias for set_linewidth.
matplotlib.patches.Patch#Create boxes from error bars using PatchCollection
Plot a confidence ellipse of a two-dimensional dataset
Controlling view limits using margins and sticky_edges
Building histograms using Rectangles and PolyCollections
SkewT-logP diagram: using transforms and custom projections
| Web Proxy Viewer | New URL | Original Page |