get_legend_handler_map()[source]

Return the handler map.


get_lines()[source]

Return the list of Line2Ds in the legend.


get_patches()[source]

Return the list of Patchs in the legend.


get_texts()[source]

Return the list of Texts in the legend.


get_tightbbox(renderer)[source]

Like Artist.get_window_extent, but includes any clipping.  Parameters

rendererRendererBase subclass

renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())    Returns
 Bbox

The enclosing bounding box (in figure pixel coordinates).


get_title()[source]

Return the Text instance for the legend title.


get_window_extent(renderer=None)[source]

Get the artist's bounding box in display space. The bounding box' width and height are nonnegative. Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0. Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.


set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, bbox_to_anchor=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, draggable=<UNSET>, frame_on=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, title=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once. Supported properties are
Property Description
agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha scalar or None
animated bool
bbox_to_anchor BboxBase or tuple
clip_box Bbox
clip_on bool
clip_path Patch or (Path, Transform) or None
draggable bool
figure Figure
frame_on bool
gid str
in_layout bool
label object
path_effects AbstractPathEffect
picker None or bool or float or callable
rasterized bool
sketch_params (scale: float, length: float, randomness: float)
snap bool or None
title unknown
transform Transform
url str
visible bool
zorder float


set_bbox_to_anchor(bbox, transform=None)[source]

Set the bbox that the legend will be anchored to.  Parameters

bboxBboxBase or tuple

The bounding box can be specified in the following ways:  A BboxBase instance A tuple of (left, bottom, width, height) in the given transform (normalized axes coordinate if None) A tuple of (left, bottom) where the width and height will be assumed to be zero.
None, to remove the bbox anchoring, and use the parent bbox.
transformTransform, optional

A transform to apply to the bounding box. If not specified, this will use a transform to the bounding box of the parent.


classmethodset_default_handler_map(handler_map)[source]

A class method to set the default handler map.


set_draggable(state, use_blit=False, update='loc')[source]

Enable or disable mouse dragging support of the legend.  Parameters

statebool

Whether mouse dragging is enabled.
use_blitbool, optional

Use blitting for faster image composition. For details see FuncAnimation.
update{'loc', 'bbox'}, optional

The legend parameter to be changed when dragged:  'loc': update the loc parameter of the legend 'bbox': update the bbox_to_anchor parameter of the legend     Returns

DraggableLegend or None

If state is True this returns the DraggableLegend helper instance. Otherwise this returns None.


set_frame_on(b)[source]

Set whether the legend box patch is drawn.  Parameters

bbool


set_title(title, prop=None)[source]

Set the legend title. Fontproperties can be optionally set with prop parameter.


classmethodupdate_default_handler_map(handler_map)[source]

A class method to update the default handler map.


matplotlib.legend_handler Default legend handlers.  Important This is a low-level legend API, which most end users do not need. We recommend that you are familiar with the legend guide before reading this documentation.  Legend handlers are expected to be a callable object with a following signature. legend_handler(legend, orig_handle, fontsize, handlebox)
 Where legend is the legend itself, orig_handle is the original plot, fontsize is the fontsize in pixels, and handlebox is a OffsetBox instance. Within the call, you should create relevant artists (using relevant properties from the legend and/or orig_handle) and add them into the handlebox. The artists needs to be scaled according to the fontsize (note that the size is in pixel, i.e., this is dpi-scaled value). This module includes definition of several legend handler classes derived from the base class (HandlerBase) with the following method: def legend_artist(self, legend, orig_handle, fontsize, handlebox)
   classmatplotlib.legend_handler.HandlerBase(xpad=0.0, ypad=0.0, update_func=None)[source]

A Base class for default legend handlers. The derived classes are meant to override create_artists method, which has a following signature.: def create_artists(self, legend, orig_handle,
                   xdescent, ydescent, width, height, fontsize,
                   trans):
 The overridden method needs to create artists of the given transform that fits in the given dimension (xdescent, ydescent, width, height) that are scaled by fontsize if necessary.   adjust_drawing_area(legend, orig_handle, xdescent, ydescent, width, height, fontsize)[source]

   create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]

   legend_artist(legend, orig_handle, fontsize, handlebox)[source]

Return the artist that this HandlerBase generates for the given original artist/handle.  Parameters

legendLegend

The legend for which these legend artists are being created.
orig_handlematplotlib.artist.Artist or similar

The object for which these legend artists are being created.
fontsizeint

The fontsize in pixels. The artists being created should be scaled according to the given fontsize.
handleboxmatplotlib.offsetbox.OffsetBox

The box which has been created to hold this legend entry's artists. Artists created in the legend_artist method must be added to this handlebox inside this method.
   update_prop(legend_handle, orig_handle, legend)[source]

   classmatplotlib.legend_handler.HandlerCircleCollection(yoffsets=None, sizes=None, **kwargs)[source]

Handler for CircleCollections.  Parameters

numpointsint

Number of points to show in legend entry.
yoffsetsarray of floats

Length numpoints list of y offsets for each point in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpoints.       create_collection(orig_handle, sizes, offsets, transOffset)[source]

   classmatplotlib.legend_handler.HandlerErrorbar(xerr_size=0.5, yerr_size=None, marker_pad=0.3, numpoints=None, **kwargs)[source]

Handler for Errorbars.  Parameters

marker_padfloat

Padding between points in legend entry.
numpointsint

Number of points to show in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpoints.       create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]

   get_err_size(legend, xdescent, ydescent, width, height, fontsize)[source]

   classmatplotlib.legend_handler.HandlerLine2D(marker_pad=0.3, numpoints=None, **kw)[source]

Handler for Line2D instances.  See also  HandlerLine2DCompound

An earlier handler implementation, which used one artist for the line and another for the marker(s).     Parameters

marker_padfloat

Padding between points in legend entry.
numpointsint

Number of points to show in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpoints.       create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]

   classmatplotlib.legend_handler.HandlerLine2DCompound(marker_pad=0.3, numpoints=None, **kwargs)[source]

Original handler for Line2D instances, that relies on combining a line-only with a marker-only artist. May be deprecated in the future.  Parameters

marker_padfloat

Padding between points in legend entry.
numpointsint

Number of points to show in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpoints.       create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]

   classmatplotlib.legend_handler.HandlerLineCollection(marker_pad=0.3, numpoints=None, **kw)[source]

Handler for LineCollection instances.  Parameters

marker_padfloat

Padding between points in legend entry.
numpointsint

Number of points to show in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpoints.       create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]

   get_numpoints(legend)[source]

   classmatplotlib.legend_handler.HandlerNpoints(marker_pad=0.3, numpoints=None, **kwargs)[source]

A legend handler that shows numpoints points in the legend entry.  Parameters

marker_padfloat

Padding between points in legend entry.
numpointsint

Number of points to show in legend entry.  **kwargs

Keyword arguments forwarded to HandlerBase.       get_numpoints(legend)[source]

   get_xdata(legend, xdescent, ydescent, width, height, fontsize)[source]

   classmatplotlib.legend_handler.HandlerNpointsYoffsets(numpoints=None, yoffsets=None, **kwargs)[source]

A legend handler that shows numpoints in the legend, and allows them to be individually offset in the y-direction.  Parameters

numpointsint

Number of points to show in legend entry.
yoffsetsarray of floats

Length numpoints list of y offsets for each point in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpoints.       get_ydata(legend, xdescent, ydescent, width, height, fontsize)[source]

   classmatplotlib.legend_handler.HandlerPatch(patch_func=None, **kwargs)[source]

Handler for Patch instances.  Parameters

patch_funccallable, optional

The function that creates the legend key artist. patch_func should have the signature: def patch_func(legend=legend, orig_handle=orig_handle,
               xdescent=xdescent, ydescent=ydescent,
               width=width, height=height, fontsize=fontsize)
 Subsequently the created artist will have its update_prop method called and the appropriate transform will be applied.  **kwargs

Keyword arguments forwarded to HandlerBase.       create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]

   classmatplotlib.legend_handler.HandlerPathCollection(yoffsets=None, sizes=None, **kwargs)[source]

Handler for PathCollections, which are used by scatter.  Parameters

numpointsint

Number of points to show in legend entry.
yoffsetsarray of floats

Length numpoints list of y offsets for each point in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpoints.       create_collection(orig_handle, sizes, offsets, transOffset)[source]

   classmatplotlib.legend_handler.HandlerPolyCollection(xpad=0.0, ypad=0.0, update_func=None)[source]

Handler for PolyCollection used in fill_between and stackplot.   create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]

   classmatplotlib.legend_handler.HandlerRegularPolyCollection(yoffsets=None, sizes=None, **kwargs)[source]

Handler for RegularPolyCollections.  Parameters

numpointsint

Number of points to show in legend entry.
yoffsetsarray of floats

Length numpoints list of y offsets for each point in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpoints.       create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]

   create_collection(orig_handle, sizes, offsets, transOffset)[source]

   get_numpoints(legend)[source]

   get_sizes(legend, orig_handle, xdescent, ydescent, width, height, fontsize)[source]

   update_prop(legend_handle, orig_handle, legend)[source]

   classmatplotlib.legend_handler.HandlerStem(marker_pad=0.3, numpoints=None, bottom=None, yoffsets=None, **kwargs)[source]

Handler for plots produced by stem.  Parameters

marker_padfloat, default: 0.3

Padding between points in legend entry.
numpointsint, optional

Number of points to show in legend entry.
bottomfloat, optional

yoffsetsarray of floats, optional

Length numpoints list of y offsets for each point in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpointsYoffsets.       create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]

   get_ydata(legend, xdescent, ydescent, width, height, fontsize)[source]

   classmatplotlib.legend_handler.HandlerStepPatch(xpad=0.0, ypad=0.0, update_func=None)[source]

Handler for StepPatch instances.   create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]

   classmatplotlib.legend_handler.HandlerTuple(ndivide=1, pad=None, **kwargs)[source]

Handler for Tuple.  Parameters

ndivideint, default: 1

The number of sections to divide the legend area into. If None, use the length of the input tuple.
padfloat, default: rcParams["legend.borderpad"] (default: 0.4)

Padding in units of fraction of font size.  **kwargs

Keyword arguments forwarded to HandlerBase.       create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]

   matplotlib.legend_handler.update_from_first_child(tgt, src)[source]


classmatplotlib.legend_handler.HandlerBase(xpad=0.0, ypad=0.0, update_func=None)[source]

A Base class for default legend handlers. The derived classes are meant to override create_artists method, which has a following signature.: def create_artists(self, legend, orig_handle,
                   xdescent, ydescent, width, height, fontsize,
                   trans):
 The overridden method needs to create artists of the given transform that fits in the given dimension (xdescent, ydescent, width, height) that are scaled by fontsize if necessary.   adjust_drawing_area(legend, orig_handle, xdescent, ydescent, width, height, fontsize)[source]

   create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]

   legend_artist(legend, orig_handle, fontsize, handlebox)[source]

Return the artist that this HandlerBase generates for the given original artist/handle.  Parameters

legendLegend

The legend for which these legend artists are being created.
orig_handlematplotlib.artist.Artist or similar

The object for which these legend artists are being created.
fontsizeint

The fontsize in pixels. The artists being created should be scaled according to the given fontsize.
handleboxmatplotlib.offsetbox.OffsetBox

The box which has been created to hold this legend entry's artists. Artists created in the legend_artist method must be added to this handlebox inside this method.
   update_prop(legend_handle, orig_handle, legend)[source]


adjust_drawing_area(legend, orig_handle, xdescent, ydescent, width, height, fontsize)[source]


create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]


legend_artist(legend, orig_handle, fontsize, handlebox)[source]

Return the artist that this HandlerBase generates for the given original artist/handle.  Parameters

legendLegend

The legend for which these legend artists are being created.
orig_handlematplotlib.artist.Artist or similar

The object for which these legend artists are being created.
fontsizeint

The fontsize in pixels. The artists being created should be scaled according to the given fontsize.
handleboxmatplotlib.offsetbox.OffsetBox

The box which has been created to hold this legend entry's artists. Artists created in the legend_artist method must be added to this handlebox inside this method.


classmatplotlib.legend_handler.HandlerCircleCollection(yoffsets=None, sizes=None, **kwargs)[source]

Handler for CircleCollections.  Parameters

numpointsint

Number of points to show in legend entry.
yoffsetsarray of floats

Length numpoints list of y offsets for each point in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpoints.       create_collection(orig_handle, sizes, offsets, transOffset)[source]


create_collection(orig_handle, sizes, offsets, transOffset)[source]


classmatplotlib.legend_handler.HandlerErrorbar(xerr_size=0.5, yerr_size=None, marker_pad=0.3, numpoints=None, **kwargs)[source]

Handler for Errorbars.  Parameters

marker_padfloat

Padding between points in legend entry.
numpointsint

Number of points to show in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpoints.       create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]

   get_err_size(legend, xdescent, ydescent, width, height, fontsize)[source]


get_err_size(legend, xdescent, ydescent, width, height, fontsize)[source]


classmatplotlib.legend_handler.HandlerLine2D(marker_pad=0.3, numpoints=None, **kw)[source]

Handler for Line2D instances.  See also  HandlerLine2DCompound

An earlier handler implementation, which used one artist for the line and another for the marker(s).     Parameters

marker_padfloat

Padding between points in legend entry.
numpointsint

Number of points to show in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpoints.       create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]


classmatplotlib.legend_handler.HandlerLine2DCompound(marker_pad=0.3, numpoints=None, **kwargs)[source]

Original handler for Line2D instances, that relies on combining a line-only with a marker-only artist. May be deprecated in the future.  Parameters

marker_padfloat

Padding between points in legend entry.
numpointsint

Number of points to show in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpoints.       create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]


classmatplotlib.legend_handler.HandlerLineCollection(marker_pad=0.3, numpoints=None, **kw)[source]

Handler for LineCollection instances.  Parameters

marker_padfloat

Padding between points in legend entry.
numpointsint

Number of points to show in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpoints.       create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]

   get_numpoints(legend)[source]


classmatplotlib.legend_handler.HandlerNpoints(marker_pad=0.3, numpoints=None, **kwargs)[source]

A legend handler that shows numpoints points in the legend entry.  Parameters

marker_padfloat

Padding between points in legend entry.
numpointsint

Number of points to show in legend entry.  **kwargs

Keyword arguments forwarded to HandlerBase.       get_numpoints(legend)[source]

   get_xdata(legend, xdescent, ydescent, width, height, fontsize)[source]


get_xdata(legend, xdescent, ydescent, width, height, fontsize)[source]


classmatplotlib.legend_handler.HandlerNpointsYoffsets(numpoints=None, yoffsets=None, **kwargs)[source]

A legend handler that shows numpoints in the legend, and allows them to be individually offset in the y-direction.  Parameters

numpointsint

Number of points to show in legend entry.
yoffsetsarray of floats

Length numpoints list of y offsets for each point in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpoints.       get_ydata(legend, xdescent, ydescent, width, height, fontsize)[source]


get_ydata(legend, xdescent, ydescent, width, height, fontsize)[source]


classmatplotlib.legend_handler.HandlerPatch(patch_func=None, **kwargs)[source]

Handler for Patch instances.  Parameters

patch_funccallable, optional

The function that creates the legend key artist. patch_func should have the signature: def patch_func(legend=legend, orig_handle=orig_handle,
               xdescent=xdescent, ydescent=ydescent,
               width=width, height=height, fontsize=fontsize)
 Subsequently the created artist will have its update_prop method called and the appropriate transform will be applied.  **kwargs

Keyword arguments forwarded to HandlerBase.       create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]


classmatplotlib.legend_handler.HandlerPathCollection(yoffsets=None, sizes=None, **kwargs)[source]

Handler for PathCollections, which are used by scatter.  Parameters

numpointsint

Number of points to show in legend entry.
yoffsetsarray of floats

Length numpoints list of y offsets for each point in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpoints.       create_collection(orig_handle, sizes, offsets, transOffset)[source]


classmatplotlib.legend_handler.HandlerPolyCollection(xpad=0.0, ypad=0.0, update_func=None)[source]

Handler for PolyCollection used in fill_between and stackplot.   create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]


classmatplotlib.legend_handler.HandlerRegularPolyCollection(yoffsets=None, sizes=None, **kwargs)[source]

Handler for RegularPolyCollections.  Parameters

numpointsint

Number of points to show in legend entry.
yoffsetsarray of floats

Length numpoints list of y offsets for each point in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpoints.       create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]

   create_collection(orig_handle, sizes, offsets, transOffset)[source]

   get_numpoints(legend)[source]

   get_sizes(legend, orig_handle, xdescent, ydescent, width, height, fontsize)[source]

   update_prop(legend_handle, orig_handle, legend)[source]


create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]


get_sizes(legend, orig_handle, xdescent, ydescent, width, height, fontsize)[source]


classmatplotlib.legend_handler.HandlerStem(marker_pad=0.3, numpoints=None, bottom=None, yoffsets=None, **kwargs)[source]

Handler for plots produced by stem.  Parameters

marker_padfloat, default: 0.3

Padding between points in legend entry.
numpointsint, optional

Number of points to show in legend entry.
bottomfloat, optional

yoffsetsarray of floats, optional

Length numpoints list of y offsets for each point in legend entry.  **kwargs

Keyword arguments forwarded to HandlerNpointsYoffsets.       create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]

   get_ydata(legend, xdescent, ydescent, width, height, fontsize)[source]


classmatplotlib.legend_handler.HandlerStepPatch(xpad=0.0, ypad=0.0, update_func=None)[source]

Handler for StepPatch instances.   create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]


classmatplotlib.legend_handler.HandlerTuple(ndivide=1, pad=None, **kwargs)[source]

Handler for Tuple.  Parameters

ndivideint, default: 1

The number of sections to divide the legend area into. If None, use the length of the input tuple.
padfloat, default: rcParams["legend.borderpad"] (default: 0.4)

Padding in units of fraction of font size.  **kwargs

Keyword arguments forwarded to HandlerBase.       create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]


matplotlib.lines 2D lines with support for a variety of line styles, markers, colors, etc.  Classes
Line2D(xdata, ydata[, linewidth, linestyle, ...]) A line - the line can have both a solid linestyle connecting all the vertices, and a marker at each vertex.
VertexSelector(line) Manage the callbacks to maintain a list of selected vertices for Line2D.     Functions
segment_hits(cx, cy, x, y, radius) Return the indices of the segments in the polyline with coordinates (cx, cy) that are within a distance radius of the point (x, y).


matplotlib.lines.Line2D   classmatplotlib.lines.Line2D(xdata, ydata, linewidth=None, linestyle=None, color=None, marker=None, markersize=None, markeredgewidth=None, markeredgecolor=None, markerfacecolor=None, markerfacecoloralt='none', fillstyle=None, antialiased=None, dash_capstyle=None, solid_capstyle=None, dash_joinstyle=None, solid_joinstyle=None, pickradius=5, drawstyle=None, markevery=None, **kwargs)[source]

Bases: matplotlib.artist.Artist A line - the line can have both a solid linestyle connecting all the vertices, and a marker at each vertex. Additionally, the drawing of the solid line is influenced by the drawstyle, e.g., one can create "stepped" lines in various styles. Create a Line2D instance with x and y data in sequences of xdata, ydata. Additional keyword arguments are Line2D properties:
Property Description
agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha scalar or None
animated bool
antialiased or aa bool
clip_box Bbox
clip_on bool
clip_path Patch or (Path, Transform) or None
color or c color
dash_capstyle CapStyle or {'butt', 'projecting', 'round'}
dash_joinstyle JoinStyle or {'miter', 'round', 'bevel'}
dashes sequence of floats (on/off ink in points) or (None, None)
data (2, N) array or two 1D arrays
drawstyle or ds {'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default'
figure Figure
fillstyle {'full', 'left', 'right', 'bottom', 'top', 'none'}
gid str
in_layout bool
label object
linestyle or ls {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth or lw float
marker marker style string, Path or MarkerStyle
markeredgecolor or mec color
markeredgewidth or mew float
markerfacecolor or mfc color
markerfacecoloralt or mfcalt color
markersize or ms float
markevery None or int or (int, int) or slice or list[int] or float or (float, float) or list[bool]
path_effects AbstractPathEffect
picker float or callable[[Artist, Event], tuple[bool, dict]]
pickradius float
rasterized bool
sketch_params (scale: float, length: float, randomness: float)
snap bool or None
solid_capstyle CapStyle or {'butt', 'projecting', 'round'}
solid_joinstyle JoinStyle or {'miter', 'round', 'bevel'}
transform unknown
url str
visible bool
xdata 1D array
ydata 1D array
zorder float   See set_linestyle() for a description of the line styles, set_marker() for a description of the markers, and set_drawstyle() for a description of the draw styles.   contains(mouseevent)[source]

Test whether mouseevent occurred on the line. An event is deemed to have occurred "on" the line if it is less than self.pickradius (default: 5 points) away from it. Use get_pickradius or set_pickradius to get or set the pick radius.  Parameters

mouseeventmatplotlib.backend_bases.MouseEvent

  Returns

containsbool

Whether any values are within the radius.
detailsdict

A dictionary {'ind': pointlist}, where pointlist is a list of points of the line that are within the pickradius around the event position. TODO: sort returned indices by distance
   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_visible returns False).  Parameters

rendererRendererBase subclass.

   Notes This method is overridden in the Artist subclasses.
   drawStyleKeys=['default', 'steps-mid', 'steps-pre', 'steps-post', 'steps']

   drawStyles={'default': '_draw_lines', 'steps': '_draw_steps_pre', 'steps-mid': '_draw_steps_mid', 'steps-post': '_draw_steps_post', 'steps-pre': '_draw_steps_pre'}

   fillStyles=('full', 'left', 'right', 'bottom', 'top', 'none')

   filled_markers=('o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd', 'P', 'X')

   get_aa()[source]

Alias for get_antialiased.
   get_antialiased()[source]

Return whether antialiased rendering is used.
   get_c()[source]

Alias for get_color.
   get_color()[source]

Return the line color. See also set_color.
   get_dash_capstyle()[source]

Return the CapStyle for dashed lines. See also set_dash_capstyle.
   get_dash_joinstyle()[source]

Return the JoinStyle for dashed lines. See also set_dash_joinstyle.
   get_data(orig=True)[source]

Return the line data as an (xdata, ydata) pair. If orig is True, return the original data.
   get_drawstyle()[source]

Return the drawstyle. See also set_drawstyle.
   get_ds()[source]

Alias for get_drawstyle.
   get_fillstyle()[source]

Return the marker fill style. See also set_fillstyle.
   get_linestyle()[source]

Return the linestyle. See also set_linestyle.
   get_linewidth()[source]

Return the linewidth in points. See also set_linewidth.
   get_ls()[source]

Alias for get_linestyle.
   get_lw()[source]

Alias for get_linewidth.
   get_marker()[source]

Return the line marker. See also set_marker.
   get_markeredgecolor()[source]

Return the marker edge color. See also set_markeredgecolor.
   get_markeredgewidth()[source]

Return the marker edge width in points. See also set_markeredgewidth.
   get_markerfacecolor()[source]

Return the marker face color. See also set_markerfacecolor.
   get_markerfacecoloralt()[source]

Return the alternate marker face color. See also set_markerfacecoloralt.
   get_markersize()[source]

Return the marker size in points. See also set_markersize.
   get_markevery()[source]

Return the markevery setting for marker subsampling. See also set_markevery.
   get_mec()[source]

Alias for get_markeredgecolor.
   get_mew()[source]

Alias for get_markeredgewidth.
   get_mfc()[source]

Alias for get_markerfacecolor.
   get_mfcalt()[source]

Alias for get_markerfacecoloralt.
   get_ms()[source]

Alias for get_markersize.
   get_path()[source]

Return the Path associated with this line.
   get_pickradius()[source]

Return the pick radius used for containment tests. See contains for more details.
   get_solid_capstyle()[source]

Return the CapStyle for solid lines. See also set_solid_capstyle.
   get_solid_joinstyle()[source]

Return the JoinStyle for solid lines. See also set_solid_joinstyle.
   get_window_extent(renderer)[source]

Get the artist's bounding box in display space. The bounding box' width and height are nonnegative. Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0. Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
   get_xdata(orig=True)[source]

Return the xdata. If orig is True, return the original data, else the processed data.
   get_xydata()[source]

Return the xy data as a Nx2 numpy array.
   get_ydata(orig=True)[source]

Return the ydata. If orig is True, return the original data, else the processed data.
   is_dashed()[source]

Return whether line has a dashed linestyle. A custom linestyle is assumed to be dashed, we do not inspect the onoffseq directly. See also set_linestyle.
   lineStyles={'': '_draw_nothing', ' ': '_draw_nothing', '-': '_draw_solid', '--': '_draw_dashed', '-.': '_draw_dash_dot', ':': '_draw_dotted', 'None': '_draw_nothing'}

   markers={'.': 'point', ',': 'pixel', 'o': 'circle', 'v': 'triangle_down', '^': 'triangle_up', '<': 'triangle_left', '>': 'triangle_right', '1': 'tri_down', '2': 'tri_up', '3': 'tri_left', '4': 'tri_right', '8': 'octagon', 's': 'square', 'p': 'pentagon', '*': 'star', 'h': 'hexagon1', 'H': 'hexagon2', '+': 'plus', 'x': 'x', 'D': 'diamond', 'd': 'thin_diamond', '|': 'vline', '_': 'hline', 'P': 'plus_filled', 'X': 'x_filled', 0: 'tickleft', 1: 'tickright', 2: 'tickup', 3: 'tickdown', 4: 'caretleft', 5: 'caretright', 6: 'caretup', 7: 'caretdown', 8: 'caretleftbase', 9: 'caretrightbase', 10: 'caretupbase', 11: 'caretdownbase', 'None': 'nothing', None: 'nothing', ' ': 'nothing', '': 'nothing'}

   propertypickradius

Return the pick radius used for containment tests. See contains for more details.
   recache(always=False)[source]

   recache_always()[source]

   set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, dash_capstyle=<UNSET>, dash_joinstyle=<UNSET>, dashes=<UNSET>, data=<UNSET>, drawstyle=<UNSET>, fillstyle=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, marker=<UNSET>, markeredgecolor=<UNSET>, markeredgewidth=<UNSET>, markerfacecolor=<UNSET>, markerfacecoloralt=<UNSET>, markersize=<UNSET>, markevery=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, solid_capstyle=<UNSET>, solid_joinstyle=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, xdata=<UNSET>, ydata=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once. Supported properties are
Property Description
agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha scalar or None
animated bool
antialiased bool
clip_box Bbox
clip_on bool
clip_path Patch or (Path, Transform) or None
color color
dash_capstyle CapStyle or {'butt', 'projecting', 'round'}
dash_joinstyle JoinStyle or {'miter', 'round', 'bevel'}
dashes sequence of floats (on/off ink in points) or (None, None)
data (2, N) array or two 1D arrays
drawstyle {'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default'
figure Figure
fillstyle {'full', 'left', 'right', 'bottom', 'top', 'none'}
gid str
in_layout bool
label object
linestyle {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth float
marker marker style string, Path or MarkerStyle
markeredgecolor color
markeredgewidth float
markerfacecolor color
markerfacecoloralt color
markersize float
markevery None or int or (int, int) or slice or list[int] or float or (float, float) or list[bool]
path_effects AbstractPathEffect
picker float or callable[[Artist, Event], tuple[bool, dict]]
pickradius float
rasterized bool
sketch_params (scale: float, length: float, randomness: float)
snap bool or None
solid_capstyle CapStyle or {'butt', 'projecting', 'round'}
solid_joinstyle JoinStyle or {'miter', 'round', 'bevel'}
transform unknown
url str
visible bool
xdata 1D array
ydata 1D array
zorder float
   set_aa(b)[source]

Alias for set_antialiased.
   set_antialiased(b)[source]

Set whether to use antialiased rendering.  Parameters

bbool

   set_c(color)[source]

Alias for set_color.
   set_color(color)[source]

Set the color of the line.  Parameters

colorcolor

   set_dash_capstyle(s)[source]

How to draw the end caps if the line is is_dashed.  Parameters

sCapStyle or {'butt', 'projecting', 'round'}

   set_dash_joinstyle(s)[source]

How to join segments of the line if it is_dashed.  Parameters

sJoinStyle or {'miter', 'round', 'bevel'}

   set_dashes(seq)[source]

Set the dash sequence. The dash sequence is a sequence of floats of even length describing the length of dashes and spaces in points. For example, (5, 2, 1, 2) describes a sequence of 5 point and 1 point dashes separated by 2 point spaces.  Parameters

seqsequence of floats (on/off ink in points) or (None, None)

If seq is empty or (None, None), the linestyle will be set to solid.
   set_data(*args)[source]

Set the x and y data.  Parameters

*args(2, N) array or two 1D arrays

   set_drawstyle(drawstyle)[source]

Set the drawstyle of the plot. The drawstyle determines how the points are connected.  Parameters

drawstyle{'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default'

For 'default', the points are connected with straight lines. The steps variants connect the points with step-like lines, i.e. horizontal lines with vertical steps. They differ in the location of the step:  'steps-pre': The step is at the beginning of the line segment, i.e. the line will be at the y-value of point to the right. 'steps-mid': The step is halfway between the points. 'steps-post: The step is at the end of the line segment, i.e. the line will be at the y-value of the point to the left. 'steps' is equal to 'steps-pre' and is maintained for backward-compatibility.  For examples see Step Demo.
   set_ds(drawstyle)[source]

Alias for set_drawstyle.
   set_fillstyle(fs)[source]

Set the marker fill style.  Parameters

fs{'full', 'left', 'right', 'bottom', 'top', 'none'}

Possible values:  'full': Fill the whole marker with the markerfacecolor. 'left', 'right', 'bottom', 'top': Fill the marker half at the given side with the markerfacecolor. The other half of the marker is filled with markerfacecoloralt. 'none': No filling.  For examples see Marker fill styles.
   set_linestyle(ls)[source]

Set the linestyle of the line.  Parameters

ls{'-', '--', '-.', ':', '', (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
'none', 'None', ' ', or '' draw nothing
Alternatively a dash tuple of the following form can be provided: (offset, onoffseq)
 where onoffseq is an even length tuple of on and off ink in points. See also set_dashes().   For examples see Linestyles.
   set_linewidth(w)[source]

Set the line width in points.  Parameters

wfloat

Line width, in points.
   set_ls(ls)[source]

Alias for set_linestyle.
   set_lw(w)[source]

Alias for set_linewidth.
   set_marker(marker)[source]

Set the line marker.  Parameters

markermarker style string, Path or MarkerStyle

See markers for full description of possible arguments.
   set_markeredgecolor(ec)[source]

Set the marker edge color.  Parameters

eccolor

   set_markeredgewidth(ew)[source]

Set the marker edge width in points.  Parameters

ewfloat

Marker edge width, in points.
   set_markerfacecolor(fc)[source]

Set the marker face color.  Parameters

fccolor

   set_markerfacecoloralt(fc)[source]

Set the alternate marker face color.  Parameters

fccolor

   set_markersize(sz)[source]

Set the marker size in points.  Parameters

szfloat

Marker size, in points.
   set_markevery(every)[source]

Set the markevery property to subsample the plot when using markers. e.g., if every=5, every 5-th marker will be plotted.  Parameters

everyNone or int or (int, int) or slice or list[int] or float or (float, float) or list[bool]

Which markers to plot.
every=None: every point will be plotted.
every=N: every N-th marker will be plotted starting with marker 0.
every=(start, N): every N-th marker, starting at index start, will be plotted.
every=slice(start, end, N): every N-th marker, starting at index start, up to but not including index end, will be plotted.
every=[i, j, m, ...]: only markers at the given indices will be plotted.
every=[True, False, True, ...]: only positions that are True will be plotted. The list must have the same length as the data points.
every=0.1, (i.e. a float): markers will be spaced at approximately equal visual distances along the line; the distance along the line between markers is determined by multiplying the display-coordinate distance of the axes bounding-box diagonal by the value of every.
every=(0.5, 0.1) (i.e. a length-2 tuple of float): similar to every=0.1 but the first marker will be offset along the line by 0.5 multiplied by the display-coordinate-diagonal-distance along the line.  For examples see Markevery Demo.     Notes Setting markevery will still only draw markers at actual data points. While the float argument form aims for uniform visual spacing, it has to coerce from the ideal spacing to the nearest available data point. Depending on the number and distribution of data points, the result may still not look evenly spaced. When using a start offset to specify the first marker, the offset will be from the first data point which may be different from the first the visible data point if the plot is zoomed in. If zooming in on a plot when using float arguments then the actual data points that have markers will change because the distance between markers is always determined from the display-coordinates axes-bounding-box-diagonal regardless of the actual axes data limits.
   set_mec(ec)[source]

Alias for set_markeredgecolor.
   set_mew(ew)[source]

Alias for set_markeredgewidth.
   set_mfc(fc)[source]

Alias for set_markerfacecolor.
   set_mfcalt(fc)[source]

Alias for set_markerfacecoloralt.
   set_ms(sz)[source]

Alias for set_markersize.
   set_picker(p)[source]

Set the event picker details for the line.  Parameters

pfloat or callable[[Artist, Event], tuple[bool, dict]]

If a float, it is used as the pick radius in points.
   set_pickradius(d)[source]

Set the pick radius used for containment tests. See contains for more details.  Parameters

dfloat

Pick radius, in points.
   set_solid_capstyle(s)[source]

How to draw the end caps if the line is solid (not is_dashed)  Parameters

sCapStyle or {'butt', 'projecting', 'round'}

   set_solid_joinstyle(s)[source]

How to join segments if the line is solid (not is_dashed).  Parameters

sJoinStyle or {'miter', 'round', 'bevel'}

   set_transform(t)[source]

Set the artist transform.  Parameters

tTransform

   set_xdata(x)[source]

Set the data array for x.  Parameters

x1D array

   set_ydata(y)[source]

Set the data array for y.  Parameters

y1D array

   update_from(other)[source]

Copy properties from other to self.
   validCap=('butt', 'projecting', 'round')

   validJoin=('miter', 'round', 'bevel')

   zorder=2

  Examples using matplotlib.lines.Line2D

   Customizing dashed line styles

   Stem Plot

   Figure labels: suptitle, supxlabel, supylabel

   Boxplots

   Scale invariant angle label

   Annotating Plots

   Composing Custom Legends

   Annotation arrow style reference

   Figure legend demo

   Legend Demo

   Artist within an artist

   Annotating a plot

   Annotation Polar

   Fig Axes Customize Simple

   Simple axes labels

   Adding lines to figures

   Reference for Matplotlib artists

   PathPatch object

   Parasite Simple

   Parasite Axes demo

   Parasite axis demo

   Bachelor's degrees by gender

   Decay

   The double pendulum problem

   Animated line plot

   Oscilloscope

   MATPLOTLIB UNCHAINED

   Data Browser

   Legend Picking

   Looking Glass

   Pick Event Demo

   Pick Event Demo2

   Poly Editor

   Resampling Data

   Anchored Artists

   Cross hair cursor

   Patheffect Demo

   Set and get properties

   SVG Filter Line

   SkewT-logP diagram: using transforms and custom projections

   Multiple Yaxis With Spines

   Artist tests

   Simple Legend02

   Annotated Cursor

   Buttons

   Check Buttons

   Radio Buttons

   Thresholding an Image with RangeSlider

   Slider

   Snapping Sliders to Discrete Values

   Span Selector

   Textbox

   Basic Usage

   Pyplot tutorial

   Artist tutorial

   Legend guide

   Faster rendering by using blitting

   Transformations Tutorial


contains(mouseevent)[source]

Test whether mouseevent occurred on the line. An event is deemed to have occurred "on" the line if it is less than self.pickradius (default: 5 points) away from it. Use get_pickradius or set_pickradius to get or set the pick radius.  Parameters

mouseeventmatplotlib.backend_bases.MouseEvent

  Returns

containsbool

Whether any values are within the radius.
detailsdict

A dictionary {'ind': pointlist}, where pointlist is a list of points of the line that are within the pickradius around the event position. TODO: sort returned indices by distance


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_visible returns False).  Parameters

rendererRendererBase subclass.

   Notes This method is overridden in the Artist subclasses.


drawStyleKeys=['default', 'steps-mid', 'steps-pre', 'steps-post', 'steps']


drawStyles={'default': '_draw_lines', 'steps': '_draw_steps_pre', 'steps-mid': '_draw_steps_mid', 'steps-post': '_draw_steps_post', 'steps-pre': '_draw_steps_pre'}


fillStyles=('full', 'left', 'right', 'bottom', 'top', 'none')


get_aa()[source]

Alias for get_antialiased.


get_antialiased()[source]

Return whether antialiased rendering is used.


get_color()[source]

Return the line color. See also set_color.


get_dash_capstyle()[source]

Return the CapStyle for dashed lines. See also set_dash_capstyle.


get_dash_joinstyle()[source]

Return the JoinStyle for dashed lines. See also set_dash_joinstyle.


get_data(orig=True)[source]

Return the line data as an (xdata, ydata) pair. If orig is True, return the original data.


get_drawstyle()[source]

Return the drawstyle. See also set_drawstyle.


get_ds()[source]

Alias for get_drawstyle.


get_fillstyle()[source]

Return the marker fill style. See also set_fillstyle.


get_linestyle()[source]

Return the linestyle. See also set_linestyle.


get_linewidth()[source]

Return the linewidth in points. See also set_linewidth.


get_ls()[source]

Alias for get_linestyle.


get_lw()[source]

Alias for get_linewidth.


get_marker()[source]

Return the line marker. See also set_marker.


get_markeredgecolor()[source]

Return the marker edge color. See also set_markeredgecolor.


get_markeredgewidth()[source]

Return the marker edge width in points. See also set_markeredgewidth.


get_markerfacecolor()[source]

Return the marker face color. See also set_markerfacecolor.


get_markerfacecoloralt()[source]

Return the alternate marker face color. See also set_markerfacecoloralt.


get_markersize()[source]

Return the marker size in points. See also set_markersize.


get_markevery()[source]

Return the markevery setting for marker subsampling. See also set_markevery.


get_mec()[source]

Alias for get_markeredgecolor.


get_mew()[source]

Alias for get_markeredgewidth.


get_mfc()[source]

Alias for get_markerfacecolor.


get_mfcalt()[source]

Alias for get_markerfacecoloralt.


get_ms()[source]

Alias for get_markersize.


get_path()[source]

Return the Path associated with this line.


get_pickradius()[source]

Return the pick radius used for containment tests. See contains for more details.


get_solid_capstyle()[source]

Return the CapStyle for solid lines. See also set_solid_capstyle.


get_solid_joinstyle()[source]

Return the JoinStyle for solid lines. See also set_solid_joinstyle.


get_window_extent(renderer)[source]

Get the artist's bounding box in display space. The bounding box' width and height are nonnegative. Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0. Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.


get_xdata(orig=True)[source]

Return the xdata. If orig is True, return the original data, else the processed data.


get_xydata()[source]

Return the xy data as a Nx2 numpy array.


get_ydata(orig=True)[source]

Return the ydata. If orig is True, return the original data, else the processed data.


is_dashed()[source]

Return whether line has a dashed linestyle. A custom linestyle is assumed to be dashed, we do not inspect the onoffseq directly. See also set_linestyle.


lineStyles={'': '_draw_nothing', ' ': '_draw_nothing', '-': '_draw_solid', '--': '_draw_dashed', '-.': '_draw_dash_dot', ':': '_draw_dotted', 'None': '_draw_nothing'}


markers={'.': 'point', ',': 'pixel', 'o': 'circle', 'v': 'triangle_down', '^': 'triangle_up', '<': 'triangle_left', '>': 'triangle_right', '1': 'tri_down', '2': 'tri_up', '3': 'tri_left', '4': 'tri_right', '8': 'octagon', 's': 'square', 'p': 'pentagon', '*': 'star', 'h': 'hexagon1', 'H': 'hexagon2', '+': 'plus', 'x': 'x', 'D': 'diamond', 'd': 'thin_diamond', '|': 'vline', '_': 'hline', 'P': 'plus_filled', 'X': 'x_filled', 0: 'tickleft', 1: 'tickright', 2: 'tickup', 3: 'tickdown', 4: 'caretleft', 5: 'caretright', 6: 'caretup', 7: 'caretdown', 8: 'caretleftbase', 9: 'caretrightbase', 10: 'caretupbase', 11: 'caretdownbase', 'None': 'nothing', None: 'nothing', ' ': 'nothing', '': 'nothing'}


set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, dash_capstyle=<UNSET>, dash_joinstyle=<UNSET>, dashes=<UNSET>, data=<UNSET>, drawstyle=<UNSET>, fillstyle=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, marker=<UNSET>, markeredgecolor=<UNSET>, markeredgewidth=<UNSET>, markerfacecolor=<UNSET>, markerfacecoloralt=<UNSET>, markersize=<UNSET>, markevery=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, solid_capstyle=<UNSET>, solid_joinstyle=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, xdata=<UNSET>, ydata=<UNSET>, zorder=<UNSET>)[source]

Set multiple properties at once. Supported properties are
Property Description
agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha scalar or None
animated bool
antialiased bool
clip_box Bbox
clip_on bool
clip_path Patch or (Path, Transform) or None
color color
dash_capstyle CapStyle or {'butt', 'projecting', 'round'}
dash_joinstyle JoinStyle or {'miter', 'round', 'bevel'}
dashes sequence of floats (on/off ink in points) or (None, None)
data (2, N) array or two 1D arrays
drawstyle {'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default'
figure Figure
fillstyle {'full', 'left', 'right', 'bottom', 'top', 'none'}
gid str
in_layout bool
label object
linestyle {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth float
marker marker style string, Path or MarkerStyle
markeredgecolor color
markeredgewidth float
markerfacecolor color
markerfacecoloralt color
markersize float
markevery None or int or (int, int) or slice or list[int] or float or (float, float) or list[bool]
path_effects AbstractPathEffect
picker float or callable[[Artist, Event], tuple[bool, dict]]
pickradius float
rasterized bool
sketch_params (scale: float, length: float, randomness: float)
snap bool or None
solid_capstyle CapStyle or {'butt', 'projecting', 'round'}
solid_joinstyle JoinStyle or {'miter', 'round', 'bevel'}
transform unknown
url str
visible bool
xdata 1D array
ydata 1D array
zorder float


set_aa(b)[source]

Alias for set_antialiased.


set_antialiased(b)[source]

Set whether to use antialiased rendering.  Parameters

bbool


set_c(color)[source]

Alias for set_color.


set_color(color)[source]

Set the color of the line.  Parameters

colorcolor


set_dash_capstyle(s)[source]

How to draw the end caps if the line is is_dashed.  Parameters

sCapStyle or {'butt', 'projecting', 'round'}


set_dash_joinstyle(s)[source]

How to join segments of the line if it is_dashed.  Parameters

sJoinStyle or {'miter', 'round', 'bevel'}


set_dashes(seq)[source]

Set the dash sequence. The dash sequence is a sequence of floats of even length describing the length of dashes and spaces in points. For example, (5, 2, 1, 2) describes a sequence of 5 point and 1 point dashes separated by 2 point spaces.  Parameters

seqsequence of floats (on/off ink in points) or (None, None)

If seq is empty or (None, None), the linestyle will be set to solid.


set_data(*args)[source]

Set the x and y data.  Parameters

*args(2, N) array or two 1D arrays


set_drawstyle(drawstyle)[source]

Set the drawstyle of the plot. The drawstyle determines how the points are connected.  Parameters

drawstyle{'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default'

For 'default', the points are connected with straight lines. The steps variants connect the points with step-like lines, i.e. horizontal lines with vertical steps. They differ in the location of the step:  'steps-pre': The step is at the beginning of the line segment, i.e. the line will be at the y-value of point to the right. 'steps-mid': The step is halfway between the points. 'steps-post: The step is at the end of the line segment, i.e. the line will be at the y-value of the point to the left. 'steps' is equal to 'steps-pre' and is maintained for backward-compatibility.  For examples see Step Demo.


set_ds(drawstyle)[source]

Alias for set_drawstyle.


set_fillstyle(fs)[source]

Set the marker fill style.  Parameters

fs{'full', 'left', 'right', 'bottom', 'top', 'none'}

Possible values:  'full': Fill the whole marker with the markerfacecolor. 'left', 'right', 'bottom', 'top': Fill the marker half at the given side with the markerfacecolor. The other half of the marker is filled with markerfacecoloralt. 'none': No filling.  For examples see Marker fill styles.


set_linestyle(ls)[source]

Set the linestyle of the line.  Parameters

ls{'-', '--', '-.', ':', '', (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
'none', 'None', ' ', or '' draw nothing
Alternatively a dash tuple of the following form can be provided: (offset, onoffseq)
 where onoffseq is an even length tuple of on and off ink in points. See also set_dashes().   For examples see Linestyles.


set_linewidth(w)[source]

Set the line width in points.  Parameters

wfloat

Line width, in points.


set_ls(ls)[source]

Alias for set_linestyle.


set_lw(w)[source]

Alias for set_linewidth.


set_marker(marker)[source]

Set the line marker.  Parameters

markermarker style string, Path or MarkerStyle

See markers for full description of possible arguments.


set_markeredgecolor(ec)[source]

Set the marker edge color.  Parameters

eccolor


set_markeredgewidth(ew)[source]

Set the marker edge width in points.  Parameters

ewfloat

Marker edge width, in points.


set_markerfacecolor(fc)[source]

Set the marker face color.  Parameters

fccolor


set_markerfacecoloralt(fc)[source]

Set the alternate marker face color.  Parameters

fccolor


set_markersize(sz)[source]

Set the marker size in points.  Parameters

szfloat

Marker size, in points.


set_markevery(every)[source]

Set the markevery property to subsample the plot when using markers. e.g., if every=5, every 5-th marker will be plotted.  Parameters

everyNone or int or (int, int) or slice or list[int] or float or (float, float) or list[bool]

Which markers to plot.
every=None: every point will be plotted.
every=N: every N-th marker will be plotted starting with marker 0.
every=(start, N): every N-th marker, starting at index start, will be plotted.
every=slice(start, end, N): every N-th marker, starting at index start, up to but not including index end, will be plotted.
every=[i, j, m, ...]: only markers at the given indices will be plotted.
every=[True, False, True, ...]: only positions that are True will be plotted. The list must have the same length as the data points.
every=0.1, (i.e. a float): markers will be spaced at approximately equal visual distances along the line; the distance along the line between markers is determined by multiplying the display-coordinate distance of the axes bounding-box diagonal by the value of every.
every=(0.5, 0.1) (i.e. a length-2 tuple of float): similar to every=0.1 but the first marker will be offset along the line by 0.5 multiplied by the display-coordinate-diagonal-distance along the line.  For examples see Markevery Demo.     Notes Setting markevery will still only draw markers at actual data points. While the float argument form aims for uniform visual spacing, it has to coerce from the ideal spacing to the nearest available data point. Depending on the number and distribution of data points, the result may still not look evenly spaced. When using a start offset to specify the first marker, the offset will be from the first data point which may be different from the first the visible data point if the plot is zoomed in. If zooming in on a plot when using float arguments then the actual data points that have markers will change because the distance between markers is always determined from the display-coordinates axes-bounding-box-diagonal regardless of the actual axes data limits.


set_mec(ec)[source]

Alias for set_markeredgecolor.


set_mew(ew)[source]

Alias for set_markeredgewidth.


set_mfc(fc)[source]

Alias for set_markerfacecolor.


set_mfcalt(fc)[source]

Alias for set_markerfacecoloralt.


set_ms(sz)[source]

Alias for set_markersize.


set_picker(p)[source]

Set the event picker details for the line.  Parameters

pfloat or callable[[Artist, Event], tuple[bool, dict]]

If a float, it is used as the pick radius in points.


set_pickradius(d)[source]

Set the pick radius used for containment tests. See contains for more details.  Parameters

dfloat

Pick radius, in points.


set_solid_capstyle(s)[source]

How to draw the end caps if the line is solid (not is_dashed)  Parameters

sCapStyle or {'butt', 'projecting', 'round'}


set_solid_joinstyle(s)[source]

How to join segments if the line is solid (not is_dashed).  Parameters

sJoinStyle or {'miter', 'round', 'bevel'}


set_transform(t)[source]

Set the artist transform.  Parameters

tTransform


set_xdata(x)[source]

Set the data array for x.  Parameters

x1D array


set_ydata(y)[source]

Set the data array for y.  Parameters

y1D array


update_from(other)[source]

Copy properties from other to self.


matplotlib.lines.segment_hits   matplotlib.lines.segment_hits(cx, cy, x, y, radius)[source]

Return the indices of the segments in the polyline with coordinates (cx, cy) that are within a distance radius of the point (x, y).


matplotlib.lines.VertexSelector   classmatplotlib.lines.VertexSelector(line)[source]

Bases: object Manage the callbacks to maintain a list of selected vertices for Line2D. Derived classes should override the process_selected method to do something with the picks. Here is an example which highlights the selected verts with red circles: import numpy as np
import matplotlib.pyplot as plt
import matplotlib.lines as lines

class HighlightSelected(lines.VertexSelector):
    def __init__(self, line, fmt='ro', **kwargs):
        lines.VertexSelector.__init__(self, line)
        self.markers, = self.axes.plot([], [], fmt, **kwargs)

    def process_selected(self, ind, xs, ys):
        self.markers.set_data(xs, ys)
        self.canvas.draw()

fig, ax = plt.subplots()
x, y = np.random.rand(2, 30)
line, = ax.plot(x, y, 'bs-', picker=5)

selector = HighlightSelected(line)
plt.show()
 Initialize the class with a Line2D. The line should already be added to an Axes and should have the picker property set.   onpick(event)[source]

When the line is picked, update the set of selected indices.
   process_selected(ind, xs, ys)[source]

Default "do nothing" implementation of the process_selected method.  Parameters

indlist of int

The indices of the selected vertices.
xs, ysarray-like

The coordinates of the selected vertices.


onpick(event)[source]

When the line is picked, update the set of selected indices.


process_selected(ind, xs, ys)[source]

Default "do nothing" implementation of the process_selected method.  Parameters

indlist of int

The indices of the selected vertices.
xs, ysarray-like

The coordinates of the selected vertices.


matplotlib.markers Functions to handle markers; used by the marker functionality of plot, scatter, and errorbar. All possible markers are defined here:
marker symbol description
"."  point
","  pixel
"o"  circle
"v"  triangle_down
"^"  triangle_up
"<"  triangle_left
">"  triangle_right
"1"  tri_down
"2"  tri_up
"3"  tri_left
"4"  tri_right
"8"  octagon
"s"  square
"p"  pentagon
"P"  plus (filled)
"*"  star
"h"  hexagon1
"H"  hexagon2
"+"  plus
"x"  x
"X"  x (filled)
"D"  diamond
"d"  thin_diamond
"|"  vline
"_"  hline
0 (TICKLEFT)  tickleft
1 (TICKRIGHT)  tickright
2 (TICKUP)  tickup
3 (TICKDOWN)  tickdown
4 (CARETLEFT)  caretleft
5 (CARETRIGHT)  caretright
6 (CARETUP)  caretup
7 (CARETDOWN)  caretdown
8 (CARETLEFTBASE)  caretleft (centered at base)
9 (CARETRIGHTBASE)  caretright (centered at base)
10 (CARETUPBASE)  caretup (centered at base)
11 (CARETDOWNBASE)  caretdown (centered at base)
"None", " " or ""  nothing
'$...$'  Render the string using mathtext. E.g "$f$" for marker showing the letter f.
verts  A list of (x, y) pairs used for Path vertices. The center of the marker is located at (0, 0) and the size is normalized, such that the created path is encapsulated inside the unit cell.
path  A Path instance.
(numsides, 0, angle)  A regular polygon with numsides sides, rotated by angle.
(numsides, 1, angle)  A star-like symbol with numsides sides, rotated by angle.
(numsides, 2, angle)  An asterisk with numsides sides, rotated by angle.   None is the default which means 'nothing', however this table is referred to from other docs for the valid inputs from marker inputs and in those cases None still means 'default'. Note that special symbols can be defined via the STIX math font, e.g. "$\u266B$". For an overview over the STIX font symbols refer to the STIX font table. Also see the STIX Fonts. Integer numbers from 0 to 11 create lines and triangles. Those are equally accessible via capitalized variables, like CARETDOWNBASE. Hence the following are equivalent: plt.plot([1, 2, 3], marker=11)
plt.plot([1, 2, 3], marker=matplotlib.markers.CARETDOWNBASE)
 Examples showing the use of markers:  Marker reference Marker examples   Classes
MarkerStyle([marker, fillstyle]) A class representing marker types.


matplotlib.markers.MarkerStyle   classmatplotlib.markers.MarkerStyle(marker=None, fillstyle=None)[source]

Bases: object A class representing marker types. Instances are immutable. If you need to change anything, create a new instance.  Attributes

markerslist

All known markers.
filled_markerslist

All known filled markers. This is a subset of markers.
fillstyleslist

The supported fillstyles.      Parameters

markerstr, array-like, Path, MarkerStyle, or None, default: None

 Another instance of MarkerStyle copies the details of that marker.
None means no marker. For other possible marker values see the module docstring matplotlib.markers.
fillstylestr, default: rcParams["markers.fillstyle"] (default: 'full')

One of 'full', 'left', 'right', 'bottom', 'top', 'none'.       filled_markers=('o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd', 'P', 'X')

   fillstyles=('full', 'left', 'right', 'bottom', 'top', 'none')

   get_alt_path()[source]

Return a Path for the alternate part of the marker. For unfilled markers, this is None; for filled markers, this is the area to be drawn with markerfacecoloralt.
   get_alt_transform()[source]

Return the transform to be applied to the Path from MarkerStyle.get_alt_path().
   get_capstyle()[source]

   get_fillstyle()[source]

   get_joinstyle()[source]

   get_marker()[source]

   get_path()[source]

Return a Path for the primary part of the marker. For unfilled markers this is the whole marker, for filled markers, this is the area to be drawn with markerfacecolor.
   get_snap_threshold()[source]

   get_transform()[source]

Return the transform to be applied to the Path from MarkerStyle.get_path().
   is_filled()[source]

   markers={'.': 'point', ',': 'pixel', 'o': 'circle', 'v': 'triangle_down', '^': 'triangle_up', '<': 'triangle_left', '>': 'triangle_right', '1': 'tri_down', '2': 'tri_up', '3': 'tri_left', '4': 'tri_right', '8': 'octagon', 's': 'square', 'p': 'pentagon', '*': 'star', 'h': 'hexagon1', 'H': 'hexagon2', '+': 'plus', 'x': 'x', 'D': 'diamond', 'd': 'thin_diamond', '|': 'vline', '_': 'hline', 'P': 'plus_filled', 'X': 'x_filled', 0: 'tickleft', 1: 'tickright', 2: 'tickup', 3: 'tickdown', 4: 'caretleft', 5: 'caretright', 6: 'caretup', 7: 'caretdown', 8: 'caretleftbase', 9: 'caretrightbase', 10: 'caretupbase', 11: 'caretdownbase', 'None': 'nothing', None: 'nothing', ' ': 'nothing', '': 'nothing'}

   set_fillstyle(fillstyle)[source]

[Deprecated] Notes  Deprecated since version 3.4:
   set_marker(marker)[source]

[Deprecated] Notes  Deprecated since version 3.4:


fillstyles=('full', 'left', 'right', 'bottom', 'top', 'none')


get_alt_path()[source]

Return a Path for the alternate part of the marker. For unfilled markers, this is None; for filled markers, this is the area to be drawn with markerfacecoloralt.


get_alt_transform()[source]

Return the transform to be applied to the Path from MarkerStyle.get_alt_path().


get_path()[source]

Return a Path for the primary part of the marker. For unfilled markers this is the whole marker, for filled markers, this is the area to be drawn with markerfacecolor.


get_transform()[source]

Return the transform to be applied to the Path from MarkerStyle.get_path().


markers={'.': 'point', ',': 'pixel', 'o': 'circle', 'v': 'triangle_down', '^': 'triangle_up', '<': 'triangle_left', '>': 'triangle_right', '1': 'tri_down', '2': 'tri_up', '3': 'tri_left', '4': 'tri_right', '8': 'octagon', 's': 'square', 'p': 'pentagon', '*': 'star', 'h': 'hexagon1', 'H': 'hexagon2', '+': 'plus', 'x': 'x', 'D': 'diamond', 'd': 'thin_diamond', '|': 'vline', '_': 'hline', 'P': 'plus_filled', 'X': 'x_filled', 0: 'tickleft', 1: 'tickright', 2: 'tickup', 3: 'tickdown', 4: 'caretleft', 5: 'caretright', 6: 'caretup', 7: 'caretdown', 8: 'caretleftbase', 9: 'caretrightbase', 10: 'caretupbase', 11: 'caretdownbase', 'None': 'nothing', None: 'nothing', ' ': 'nothing', '': 'nothing'}


set_fillstyle(fillstyle)[source]

[Deprecated] Notes  Deprecated since version 3.4:


set_marker(marker)[source]

[Deprecated] Notes  Deprecated since version 3.4:


matplotlib.mathtext             A module for parsing a subset of the TeX math syntax and rendering it to a Matplotlib backend. For a tutorial of its usage, see Writing mathematical expressions. This document is primarily concerned with implementation details. The module uses pyparsing to parse the TeX expression. The Bakoma distribution of the TeX Computer Modern fonts, and STIX fonts are supported. There is experimental support for using arbitrary fonts, but results may vary without proper tweaking and metrics for those fonts.   classmatplotlib.mathtext.MathTextParser(output)[source]

Bases: object Create a MathTextParser for the given backend output.   get_depth(texstr, dpi=120, fontsize=14)[source]

[Deprecated] Get the depth of a mathtext string.  Parameters

texstrstr

A valid mathtext string, e.g., r'IQ: $sigma_i=15$'.
dpifloat

The dots-per-inch setting used to render the text.    Returns
 int

Offset of the baseline from the bottom of the image, in pixels.     Notes  Deprecated since version 3.4.
   parse(s, dpi=72, prop=None, *, _force_standard_ps_fonts=False)[source]

Parse the given math expression s at the given dpi. If prop is provided, it is a FontProperties object specifying the "default" font to use in the math expression, used for all non-math text. The results are cached, so multiple calls to parse with the same expression should be fast.
   to_mask(texstr, dpi=120, fontsize=14)[source]

[Deprecated] Convert a mathtext string to a grayscale array and depth.  Parameters

texstrstr

A valid mathtext string, e.g., r'IQ: $sigma_i=15$'.
dpifloat

The dots-per-inch setting used to render the text.
fontsizeint

The font size in points    Returns

array2D uint8 alpha

Mask array of rasterized tex.
depthint

Offset of the baseline from the bottom of the image, in pixels.     Notes  Deprecated since version 3.4.
   to_png(filename, texstr, color='black', dpi=120, fontsize=14)[source]

[Deprecated] Render a tex expression to a PNG file.  Parameters
 filename

A writable filename or fileobject.
texstrstr

A valid mathtext string, e.g., r'IQ: $sigma_i=15$'.
colorcolor

The text color.
dpifloat

The dots-per-inch setting used to render the text.
fontsizeint

The font size in points.    Returns
 int

Offset of the baseline from the bottom of the image, in pixels.     Notes  Deprecated since version 3.4.
   to_rgba(texstr, color='black', dpi=120, fontsize=14)[source]

[Deprecated] Convert a mathtext string to an RGBA array and depth.  Parameters

texstrstr

A valid mathtext string, e.g., r'IQ: $sigma_i=15$'.
colorcolor

The text color.
dpifloat

The dots-per-inch setting used to render the text.
fontsizeint

The font size in points.    Returns

array(M, N, 4) array

RGBA color values of rasterized tex, colorized with color.
depthint

Offset of the baseline from the bottom of the image, in pixels.     Notes  Deprecated since version 3.4.

   exceptionmatplotlib.mathtext.MathTextWarning[source]

Bases: Warning
   classmatplotlib.mathtext.MathtextBackend[source]

Bases: object The base class for the mathtext backend-specific code. MathtextBackend subclasses interface between mathtext and specific Matplotlib graphics backends. Subclasses need to override the following:  render_glyph() render_rect_filled() get_results()  And optionally, if you need to use a FreeType hinting style:  get_hinting_type()    get_hinting_type()[source]

Get the FreeType hinting type to use with this particular backend.
   get_results(box)[source]

Return a backend-specific tuple to return to the backend after all processing is done.
   render_glyph(ox, oy, info)[source]

Draw a glyph described by info to the reference point (ox, oy).
   render_rect_filled(x1, y1, x2, y2)[source]

Draw a filled black rectangle from (x1, y1) to (x2, y2).
   set_canvas_size(w, h, d)[source]

Set the dimension of the drawing canvas.

   classmatplotlib.mathtext.MathtextBackendAgg[source]

Bases: matplotlib.mathtext.MathtextBackend Render glyphs and rectangles to an FTImage buffer, which is later transferred to the Agg image by the Agg backend.   get_hinting_type()[source]

Get the FreeType hinting type to use with this particular backend.
   get_results(box, used_characters)[source]

Return a backend-specific tuple to return to the backend after all processing is done.
   render_glyph(ox, oy, info)[source]

Draw a glyph described by info to the reference point (ox, oy).
   render_rect_filled(x1, y1, x2, y2)[source]

Draw a filled black rectangle from (x1, y1) to (x2, y2).
   set_canvas_size(w, h, d)[source]

Set the dimension of the drawing canvas.

   classmatplotlib.mathtext.MathtextBackendBitmap[source]

Bases: matplotlib.mathtext.MathtextBackendAgg [Deprecated] Notes  Deprecated since version 3.4:     get_results(box, used_characters)[source]

Return a backend-specific tuple to return to the backend after all processing is done.

   classmatplotlib.mathtext.MathtextBackendCairo[source]

Bases: matplotlib.mathtext.MathtextBackend [Deprecated] Store information to write a mathtext rendering to the Cairo backend. Notes  Deprecated since version 3.4.    get_results(box, used_characters)[source]

Return a backend-specific tuple to return to the backend after all processing is done.
   render_glyph(ox, oy, info)[source]

Draw a glyph described by info to the reference point (ox, oy).
   render_rect_filled(x1, y1, x2, y2)[source]

Draw a filled black rectangle from (x1, y1) to (x2, y2).

   classmatplotlib.mathtext.MathtextBackendPath[source]

Bases: matplotlib.mathtext.MathtextBackend Store information to write a mathtext rendering to the text path machinery.   get_results(box, used_characters)[source]

Return a backend-specific tuple to return to the backend after all processing is done.
   render_glyph(ox, oy, info)[source]

Draw a glyph described by info to the reference point (ox, oy).
   render_rect_filled(x1, y1, x2, y2)[source]

Draw a filled black rectangle from (x1, y1) to (x2, y2).

   classmatplotlib.mathtext.MathtextBackendPdf[source]

Bases: matplotlib.mathtext.MathtextBackend [Deprecated] Store information to write a mathtext rendering to the PDF backend. Notes  Deprecated since version 3.4.    get_results(box, used_characters)[source]

Return a backend-specific tuple to return to the backend after all processing is done.
   render_glyph(ox, oy, info)[source]

Draw a glyph described by info to the reference point (ox, oy).
   render_rect_filled(x1, y1, x2, y2)[source]

Draw a filled black rectangle from (x1, y1) to (x2, y2).

   classmatplotlib.mathtext.MathtextBackendPs[source]

Bases: matplotlib.mathtext.MathtextBackend [Deprecated] Store information to write a mathtext rendering to the PostScript backend. Notes  Deprecated since version 3.4.    get_results(box, used_characters)[source]

Return a backend-specific tuple to return to the backend after all processing is done.
   render_glyph(ox, oy, info)[source]

Draw a glyph described by info to the reference point (ox, oy).
   render_rect_filled(x1, y1, x2, y2)[source]

Draw a filled black rectangle from (x1, y1) to (x2, y2).

   classmatplotlib.mathtext.MathtextBackendSvg[source]

Bases: matplotlib.mathtext.MathtextBackend [Deprecated] Store information to write a mathtext rendering to the SVG backend. Notes  Deprecated since version 3.4.    get_results(box, used_characters)[source]

Return a backend-specific tuple to return to the backend after all processing is done.
   render_glyph(ox, oy, info)[source]

Draw a glyph described by info to the reference point (ox, oy).
   render_rect_filled(x1, y1, x2, y2)[source]

Draw a filled black rectangle from (x1, y1) to (x2, y2).

   matplotlib.mathtext.get_unicode_index(symbol, math=True)[source]

Return the integer index (from the Unicode table) of symbol.  Parameters

symbolstr

A single unicode character, a TeX command (e.g. r'pi') or a Type1 symbol name (e.g. 'phi').
mathbool, default: True

If False, always treat as a single unicode character.
   matplotlib.mathtext.math_to_image(s, filename_or_obj, prop=None, dpi=None, format=None)[source]

Given a math expression, renders it in a closely-clipped bounding box to an image file.  Parameters

sstr

A math expression. The math portion must be enclosed in dollar signs.
filename_or_objstr or path-like or file-like

Where to write the image data.
propFontProperties, optional

The size and style of the text.
dpifloat, optional

The output dpi. If not set, the dpi is determined as for Figure.savefig.
formatstr, optional

The output format, e.g., 'svg', 'pdf', 'ps' or 'png'. If not set, the format is determined as for Figure.savefig.
   matplotlib.mathtext.ship(ox, oy, box)[source]

[Deprecated] Notes  Deprecated since version 3.4:


matplotlib.mathtext.get_unicode_index(symbol, math=True)[source]

Return the integer index (from the Unicode table) of symbol.  Parameters

symbolstr

A single unicode character, a TeX command (e.g. r'pi') or a Type1 symbol name (e.g. 'phi').
mathbool, default: True

If False, always treat as a single unicode character.


matplotlib.mathtext.math_to_image(s, filename_or_obj, prop=None, dpi=None, format=None)[source]

Given a math expression, renders it in a closely-clipped bounding box to an image file.  Parameters

sstr

A math expression. The math portion must be enclosed in dollar signs.
filename_or_objstr or path-like or file-like

Where to write the image data.
propFontProperties, optional

The size and style of the text.
dpifloat, optional

The output dpi. If not set, the dpi is determined as for Figure.savefig.
formatstr, optional

The output format, e.g., 'svg', 'pdf', 'ps' or 'png'. If not set, the format is determined as for Figure.savefig.


classmatplotlib.mathtext.MathtextBackend[source]

Bases: object The base class for the mathtext backend-specific code. MathtextBackend subclasses interface between mathtext and specific Matplotlib graphics backends. Subclasses need to override the following:  render_glyph() render_rect_filled() get_results()  And optionally, if you need to use a FreeType hinting style:  get_hinting_type()    get_hinting_type()[source]

Get the FreeType hinting type to use with this particular backend.
   get_results(box)[source]

Return a backend-specific tuple to return to the backend after all processing is done.
   render_glyph(ox, oy, info)[source]

Draw a glyph described by info to the reference point (ox, oy).
   render_rect_filled(x1, y1, x2, y2)[source]

Draw a filled black rectangle from (x1, y1) to (x2, y2).
   set_canvas_size(w, h, d)[source]

Set the dimension of the drawing canvas.


get_hinting_type()[source]

Get the FreeType hinting type to use with this particular backend.


get_results(box)[source]

Return a backend-specific tuple to return to the backend after all processing is done.


render_glyph(ox, oy, info)[source]

Draw a glyph described by info to the reference point (ox, oy).


render_rect_filled(x1, y1, x2, y2)[source]

Draw a filled black rectangle from (x1, y1) to (x2, y2).


set_canvas_size(w, h, d)[source]

Set the dimension of the drawing canvas.


classmatplotlib.mathtext.MathtextBackendAgg[source]

Bases: matplotlib.mathtext.MathtextBackend Render glyphs and rectangles to an FTImage buffer, which is later transferred to the Agg image by the Agg backend.   get_hinting_type()[source]

Get the FreeType hinting type to use with this particular backend.
   get_results(box, used_characters)[source]

Return a backend-specific tuple to return to the backend after all processing is done.
   render_glyph(ox, oy, info)[source]

Draw a glyph described by info to the reference point (ox, oy).
   render_rect_filled(x1, y1, x2, y2)[source]

Draw a filled black rectangle from (x1, y1) to (x2, y2).
   set_canvas_size(w, h, d)[source]

Set the dimension of the drawing canvas.


get_results(box, used_characters)[source]

Return a backend-specific tuple to return to the backend after all processing is done.


classmatplotlib.mathtext.MathtextBackendBitmap[source]

Bases: matplotlib.mathtext.MathtextBackendAgg [Deprecated] Notes  Deprecated since version 3.4:     get_results(box, used_characters)[source]

Return a backend-specific tuple to return to the backend after all processing is done.


classmatplotlib.mathtext.MathtextBackendCairo[source]

Bases: matplotlib.mathtext.MathtextBackend [Deprecated] Store information to write a mathtext rendering to the Cairo backend. Notes  Deprecated since version 3.4.    get_results(box, used_characters)[source]

Return a backend-specific tuple to return to the backend after all processing is done.
   render_glyph(ox, oy, info)[source]

Draw a glyph described by info to the reference point (ox, oy).
   render_rect_filled(x1, y1, x2, y2)[source]

Draw a filled black rectangle from (x1, y1) to (x2, y2).


classmatplotlib.mathtext.MathtextBackendPath[source]

Bases: matplotlib.mathtext.MathtextBackend Store information to write a mathtext rendering to the text path machinery.   get_results(box, used_characters)[source]

Return a backend-specific tuple to return to the backend after all processing is done.
   render_glyph(ox, oy, info)[source]

Draw a glyph described by info to the reference point (ox, oy).
   render_rect_filled(x1, y1, x2, y2)[source]

Draw a filled black rectangle from (x1, y1) to (x2, y2).


classmatplotlib.mathtext.MathtextBackendPdf[source]

Bases: matplotlib.mathtext.MathtextBackend [Deprecated] Store information to write a mathtext rendering to the PDF backend. Notes  Deprecated since version 3.4.    get_results(box, used_characters)[source]

Return a backend-specific tuple to return to the backend after all processing is done.
   render_glyph(ox, oy, info)[source]

Draw a glyph described by info to the reference point (ox, oy).
   render_rect_filled(x1, y1, x2, y2)[source]

Draw a filled black rectangle from (x1, y1) to (x2, y2).


classmatplotlib.mathtext.MathtextBackendPs[source]

Bases: matplotlib.mathtext.MathtextBackend [Deprecated] Store information to write a mathtext rendering to the PostScript backend. Notes  Deprecated since version 3.4.    get_results(box, used_characters)[source]

Return a backend-specific tuple to return to the backend after all processing is done.
   render_glyph(ox, oy, info)[source]

Draw a glyph described by info to the reference point (ox, oy).
   render_rect_filled(x1, y1, x2, y2)[source]

Draw a filled black rectangle from (x1, y1) to (x2, y2).


classmatplotlib.mathtext.MathtextBackendSvg[source]

Bases: matplotlib.mathtext.MathtextBackend [Deprecated] Store information to write a mathtext rendering to the SVG backend. Notes  Deprecated since version 3.4.    get_results(box, used_characters)[source]

Return a backend-specific tuple to return to the backend after all processing is done.
   render_glyph(ox, oy, info)[source]

Draw a glyph described by info to the reference point (ox, oy).
   render_rect_filled(x1, y1, x2, y2)[source]

Draw a filled black rectangle from (x1, y1) to (x2, y2).


classmatplotlib.mathtext.MathTextParser(output)[source]

Bases: object Create a MathTextParser for the given backend output.   get_depth(texstr, dpi=120, fontsize=14)[source]

[Deprecated] Get the depth of a mathtext string.  Parameters

texstrstr

A valid mathtext string, e.g., r'IQ: $sigma_i=15$'.
dpifloat

The dots-per-inch setting used to render the text.    Returns
 int

Offset of the baseline from the bottom of the image, in pixels.     Notes  Deprecated since version 3.4.
   parse(s, dpi=72, prop=None, *, _force_standard_ps_fonts=False)[source]

Parse the given math expression s at the given dpi. If prop is provided, it is a FontProperties object specifying the "default" font to use in the math expression, used for all non-math text. The results are cached, so multiple calls to parse with the same expression should be fast.
   to_mask(texstr, dpi=120, fontsize=14)[source]

[Deprecated] Convert a mathtext string to a grayscale array and depth.  Parameters

texstrstr

A valid mathtext string, e.g., r'IQ: $sigma_i=15$'.
dpifloat

The dots-per-inch setting used to render the text.
fontsizeint

The font size in points    Returns

array2D uint8 alpha

Mask array of rasterized tex.
depthint

Offset of the baseline from the bottom of the image, in pixels.     Notes  Deprecated since version 3.4.
   to_png(filename, texstr, color='black', dpi=120, fontsize=14)[source]

[Deprecated] Render a tex expression to a PNG file.  Parameters
 filename

A writable filename or fileobject.
texstrstr

A valid mathtext string, e.g., r'IQ: $sigma_i=15$'.
colorcolor

The text color.
dpifloat

The dots-per-inch setting used to render the text.
fontsizeint

The font size in points.    Returns
 int

Offset of the baseline from the bottom of the image, in pixels.     Notes  Deprecated since version 3.4.
   to_rgba(texstr, color='black', dpi=120, fontsize=14)[source]

[Deprecated] Convert a mathtext string to an RGBA array and depth.  Parameters

texstrstr

A valid mathtext string, e.g., r'IQ: $sigma_i=15$'.
colorcolor

The text color.
dpifloat

The dots-per-inch setting used to render the text.
fontsizeint

The font size in points.    Returns

array(M, N, 4) array

RGBA color values of rasterized tex, colorized with color.
depthint

Offset of the baseline from the bottom of the image, in pixels.     Notes  Deprecated since version 3.4.


get_depth(texstr, dpi=120, fontsize=14)[source]

[Deprecated] Get the depth of a mathtext string.  Parameters

texstrstr

A valid mathtext string, e.g., r'IQ: $sigma_i=15$'.
dpifloat

The dots-per-inch setting used to render the text.    Returns
 int

Offset of the baseline from the bottom of the image, in pixels.     Notes  Deprecated since version 3.4.


parse(s, dpi=72, prop=None, *, _force_standard_ps_fonts=False)[source]

Parse the given math expression s at the given dpi. If prop is provided, it is a FontProperties object specifying the "default" font to use in the math expression, used for all non-math text. The results are cached, so multiple calls to parse with the same expression should be fast.


to_mask(texstr, dpi=120, fontsize=14)[source]

[Deprecated] Convert a mathtext string to a grayscale array and depth.  Parameters

texstrstr

A valid mathtext string, e.g., r'IQ: $sigma_i=15$'.
dpifloat

The dots-per-inch setting used to render the text.
fontsizeint

The font size in points    Returns

array2D uint8 alpha

Mask array of rasterized tex.
depthint

Offset of the baseline from the bottom of the image, in pixels.     Notes  Deprecated since version 3.4.


to_png(filename, texstr, color='black', dpi=120, fontsize=14)[source]

[Deprecated] Render a tex expression to a PNG file.  Parameters
 filename

A writable filename or fileobject.
texstrstr

A valid mathtext string, e.g., r'IQ: $sigma_i=15$'.
colorcolor

The text color.
dpifloat

The dots-per-inch setting used to render the text.
fontsizeint

The font size in points.    Returns
 int

Offset of the baseline from the bottom of the image, in pixels.     Notes  Deprecated since version 3.4.


to_rgba(texstr, color='black', dpi=120, fontsize=14)[source]

[Deprecated] Convert a mathtext string to an RGBA array and depth.  Parameters

texstrstr

A valid mathtext string, e.g., r'IQ: $sigma_i=15$'.
colorcolor

The text color.
dpifloat

The dots-per-inch setting used to render the text.
fontsizeint

The font size in points.    Returns

array(M, N, 4) array

RGBA color values of rasterized tex, colorized with color.
depthint

Offset of the baseline from the bottom of the image, in pixels.     Notes  Deprecated since version 3.4.


exceptionmatplotlib.mathtext.MathTextWarning[source]

Bases: Warning


matplotlib.mathtext.ship(ox, oy, box)[source]

[Deprecated] Notes  Deprecated since version 3.4:


matplotlib  Backend management   matplotlib.use(backend, *, force=True)[source]

Select the backend used for rendering and GUI integration.  Parameters

backendstr

The backend to switch to. This can either be one of the standard backend names, which are case-insensitive:  interactive backends: GTK3Agg, GTK3Cairo, GTK4Agg, GTK4Cairo, MacOSX, nbAgg, QtAgg, QtCairo, TkAgg, TkCairo, WebAgg, WX, WXAgg, WXCairo, Qt5Agg, Qt5Cairo non-interactive backends: agg, cairo, pdf, pgf, ps, svg, template  or a string of the form: module://my.module.name. Switching to an interactive backend is not possible if an unrelated event loop has already been started (e.g., switching to GTK3Agg if a TkAgg window has already been opened). Switching to a non-interactive backend is always possible.
forcebool, default: True

If True (the default), raise an ImportError if the backend cannot be set up (either because it fails to import, or because an incompatible GUI interactive framework is already running); if False, silently ignore the failure.      See also  Backends
matplotlib.get_backend

   matplotlib.get_backend()[source]

Return the name of the current backend.  See also  matplotlib.use

   matplotlib.interactive(b)[source]

Set whether to redraw after every plotting command (e.g. pyplot.xlabel).
   matplotlib.is_interactive()[source]

Return whether to redraw after every plotting command.  Note This function is only intended for use in backends. End users should use pyplot.isinteractive instead.
   Default values and styling   matplotlib.rcParams[source]

An instance of RcParams for handling default Matplotlib values.
   classmatplotlib.RcParams(*args, **kwargs)[source]

A dictionary object including validation. Validating functions are defined and associated with rc parameters in matplotlib.rcsetup. The list of rcParams is:  _internal.classic_mode agg.path.chunksize animation.bitrate animation.codec animation.convert_args animation.convert_path animation.embed_limit animation.ffmpeg_args animation.ffmpeg_path animation.frame_format animation.html animation.writer axes.autolimit_mode axes.axisbelow axes.edgecolor axes.facecolor axes.formatter.limits axes.formatter.min_exponent axes.formatter.offset_threshold axes.formatter.use_locale axes.formatter.use_mathtext axes.formatter.useoffset axes.grid axes.grid.axis axes.grid.which axes.labelcolor axes.labelpad axes.labelsize axes.labelweight axes.linewidth axes.prop_cycle axes.spines.bottom axes.spines.left axes.spines.right axes.spines.top axes.titlecolor axes.titlelocation axes.titlepad axes.titlesize axes.titleweight axes.titley axes.unicode_minus axes.xmargin axes.ymargin axes.zmargin axes3d.grid backend backend_fallback boxplot.bootstrap boxplot.boxprops.color boxplot.boxprops.linestyle boxplot.boxprops.linewidth boxplot.capprops.color boxplot.capprops.linestyle boxplot.capprops.linewidth boxplot.flierprops.color boxplot.flierprops.linestyle boxplot.flierprops.linewidth boxplot.flierprops.marker boxplot.flierprops.markeredgecolor boxplot.flierprops.markeredgewidth boxplot.flierprops.markerfacecolor boxplot.flierprops.markersize boxplot.meanline boxplot.meanprops.color boxplot.meanprops.linestyle boxplot.meanprops.linewidth boxplot.meanprops.marker boxplot.meanprops.markeredgecolor boxplot.meanprops.markerfacecolor boxplot.meanprops.markersize boxplot.medianprops.color boxplot.medianprops.linestyle boxplot.medianprops.linewidth boxplot.notch boxplot.patchartist boxplot.showbox boxplot.showcaps boxplot.showfliers boxplot.showmeans boxplot.vertical boxplot.whiskerprops.color boxplot.whiskerprops.linestyle boxplot.whiskerprops.linewidth boxplot.whiskers contour.corner_mask contour.linewidth contour.negative_linestyle date.autoformatter.day date.autoformatter.hour date.autoformatter.microsecond date.autoformatter.minute date.autoformatter.month date.autoformatter.second date.autoformatter.year date.converter date.epoch date.interval_multiples docstring.hardcopy errorbar.capsize figure.autolayout figure.constrained_layout.h_pad figure.constrained_layout.hspace figure.constrained_layout.use figure.constrained_layout.w_pad figure.constrained_layout.wspace figure.dpi figure.edgecolor figure.facecolor figure.figsize figure.frameon figure.max_open_warning figure.raise_window figure.subplot.bottom figure.subplot.hspace figure.subplot.left figure.subplot.right figure.subplot.top figure.subplot.wspace figure.titlesize figure.titleweight font.cursive font.family font.fantasy font.monospace font.sans-serif font.serif font.size font.stretch font.style font.variant font.weight grid.alpha grid.color grid.linestyle grid.linewidth hatch.color hatch.linewidth hist.bins image.aspect image.cmap image.composite_image image.interpolation image.lut image.origin image.resample interactive keymap.back keymap.copy keymap.forward keymap.fullscreen keymap.grid keymap.grid_minor keymap.help keymap.home keymap.pan keymap.quit keymap.quit_all keymap.save keymap.xscale keymap.yscale keymap.zoom legend.borderaxespad legend.borderpad legend.columnspacing legend.edgecolor legend.facecolor legend.fancybox legend.fontsize legend.framealpha legend.frameon legend.handleheight legend.handlelength legend.handletextpad legend.labelcolor legend.labelspacing legend.loc legend.markerscale legend.numpoints legend.scatterpoints legend.shadow legend.title_fontsize lines.antialiased lines.color lines.dash_capstyle lines.dash_joinstyle lines.dashdot_pattern lines.dashed_pattern lines.dotted_pattern lines.linestyle lines.linewidth lines.marker lines.markeredgecolor lines.markeredgewidth lines.markerfacecolor lines.markersize lines.scale_dashes lines.solid_capstyle lines.solid_joinstyle markers.fillstyle mathtext.bf mathtext.cal mathtext.default mathtext.fallback mathtext.fontset mathtext.it mathtext.rm mathtext.sf mathtext.tt patch.antialiased patch.edgecolor patch.facecolor patch.force_edgecolor patch.linewidth path.effects path.simplify path.simplify_threshold path.sketch path.snap pcolor.shading pcolormesh.snap pdf.compression pdf.fonttype pdf.inheritcolor pdf.use14corefonts pgf.preamble pgf.rcfonts pgf.texsystem polaraxes.grid ps.distiller.res ps.fonttype ps.papersize ps.useafm ps.usedistiller savefig.bbox savefig.directory savefig.dpi savefig.edgecolor savefig.facecolor savefig.format savefig.orientation savefig.pad_inches savefig.transparent scatter.edgecolors scatter.marker svg.fonttype svg.hashsalt svg.image_inline text.antialiased text.color text.hinting text.hinting_factor text.kerning_factor text.latex.preamble text.usetex timezone tk.window_focus toolbar webagg.address webagg.open_in_browser webagg.port webagg.port_retries xaxis.labellocation xtick.alignment xtick.bottom xtick.color xtick.direction xtick.labelbottom xtick.labelcolor xtick.labelsize xtick.labeltop xtick.major.bottom xtick.major.pad xtick.major.size xtick.major.top xtick.major.width xtick.minor.bottom xtick.minor.pad xtick.minor.size xtick.minor.top xtick.minor.visible xtick.minor.width xtick.top yaxis.labellocation ytick.alignment ytick.color ytick.direction ytick.labelcolor ytick.labelleft ytick.labelright ytick.labelsize ytick.left ytick.major.left ytick.major.pad ytick.major.right ytick.major.size ytick.major.width ytick.minor.left ytick.minor.pad ytick.minor.right ytick.minor.size ytick.minor.visible ytick.minor.width ytick.right   See also  The matplotlibrc file
    find_all(pattern)[source]

Return the subset of this RcParams dictionary whose keys match, using re.search(), the given pattern.  Note Changes to the returned dictionary are not propagated to the parent RcParams dictionary.

   matplotlib.rc_context(rc=None, fname=None)

Return a context manager for temporarily changing rcParams.  Parameters

rcdict

The rcParams to temporarily set.
fnamestr or path-like

A file with Matplotlib rc settings. If both fname and rc are given, settings from rc take precedence.      See also  The matplotlibrc file
  Examples Passing explicit values via a dict: with mpl.rc_context({'interactive': False}):
    fig, ax = plt.subplots()
    ax.plot(range(3), range(3))
    fig.savefig('example.png')
    plt.close(fig)
 Loading settings from a file: with mpl.rc_context(fname='print.rc'):
    plt.plot(x, y)  # uses 'print.rc'

   matplotlib.rc(group, **kwargs)[source]

Set the current rcParams. group is the grouping for the rc, e.g., for lines.linewidth the group is lines, for axes.facecolor, the group is axes, and so on. Group may also be a list or tuple of group names, e.g., (xtick, ytick). kwargs is a dictionary attribute name/value pairs, e.g.,: rc('lines', linewidth=2, color='r')
 sets the current rcParams and is equivalent to: rcParams['lines.linewidth'] = 2
rcParams['lines.color'] = 'r'
 The following aliases are available to save typing for interactive users:
Alias Property
'lw' 'linewidth'
'ls' 'linestyle'
'c' 'color'
'fc' 'facecolor'
'ec' 'edgecolor'
'mew' 'markeredgewidth'
'aa' 'antialiased'   Thus you could abbreviate the above call as: rc('lines', lw=2, c='r')
 Note you can use python's kwargs dictionary facility to store dictionaries of default parameters. e.g., you can customize the font rc as follows: font = {'family' : 'monospace',
        'weight' : 'bold',
        'size'   : 'larger'}
rc('font', **font)  # pass in the font dict as kwargs
 This enables you to easily switch between several configurations. Use matplotlib.style.use('default') or rcdefaults() to restore the default rcParams after changes. Notes Similar functionality is available by using the normal dict interface, i.e. rcParams.update({"lines.linewidth": 2, ...}) (but rcParams.update does not support abbreviations or grouping).
   matplotlib.rcdefaults()[source]

Restore the rcParams from Matplotlib's internal default style. Style-blacklisted rcParams (defined in matplotlib.style.core.STYLE_BLACKLIST) are not updated.  See also  matplotlib.rc_file_defaults

Restore the rcParams from the rc file originally loaded by Matplotlib.  matplotlib.style.use

Use a specific style file. Call style.use('default') to restore the default style.
   matplotlib.rc_file_defaults()[source]

Restore the rcParams from the original rc file loaded by Matplotlib. Style-blacklisted rcParams (defined in matplotlib.style.core.STYLE_BLACKLIST) are not updated.
   matplotlib.rc_file(fname, *, use_default_template=True)[source]

Update rcParams from file. Style-blacklisted rcParams (defined in matplotlib.style.core.STYLE_BLACKLIST) are not updated.  Parameters

fnamestr or path-like

A file with Matplotlib rc settings.
use_default_templatebool

If True, initialize with default parameters before updating with those in the given file. If False, the current configuration persists and only the parameters specified in the file are updated.
   matplotlib.rc_params(fail_on_error=False)[source]

Construct a RcParams instance from the default Matplotlib rc file.
   matplotlib.rc_params_from_file(fname, fail_on_error=False, use_default_template=True)[source]

Construct a RcParams from file fname.  Parameters

fnamestr or path-like

A file with Matplotlib rc settings.
fail_on_errorbool

If True, raise an error when the parser fails to convert a parameter.
use_default_templatebool

If True, initialize with default parameters before updating with those in the given file. If False, the configuration class only contains the parameters specified in the file. (Useful for updating dicts.)
   matplotlib.get_configdir()[source]

Return the string path of the configuration directory. The directory is chosen as follows:  If the MPLCONFIGDIR environment variable is supplied, choose that. On Linux, follow the XDG specification and look first in $XDG_CONFIG_HOME, if defined, or $HOME/.config. On other platforms, choose $HOME/.matplotlib. If the chosen directory exists and is writable, use that as the configuration directory. Else, create a temporary directory, and use it as the configuration directory.
   matplotlib.matplotlib_fname()[source]

Get the location of the config file. The file location is determined in the following order  $PWD/matplotlibrc
$MATPLOTLIBRC if it is not a directory $MATPLOTLIBRC/matplotlibrc $MPLCONFIGDIR/matplotlibrc
 On Linux,

$XDG_CONFIG_HOME/matplotlib/matplotlibrc (if $XDG_CONFIG_HOME is defined) or $HOME/.config/matplotlib/matplotlibrc (if $XDG_CONFIG_HOME is not defined)     On other platforms, - $HOME/.matplotlib/matplotlibrc if $HOME is defined Lastly, it looks in $MATPLOTLIBDATA/matplotlibrc, which should always exist.
   matplotlib.get_data_path()[source]

Return the path to Matplotlib data.
   Logging   matplotlib.set_loglevel(level)[source]

Set Matplotlib's root logger and root logger handler level, creating the handler if it does not exist yet. Typically, one should call set_loglevel("info") or set_loglevel("debug") to get additional debugging information.  Parameters

level{"notset", "debug", "info", "warning", "error", "critical"}

The log level of the handler.     Notes The first time this function is called, an additional handler is attached to Matplotlib's root handler; this handler is reused every time and this function simply manipulates the logger and handler's level.
   Colormaps   matplotlib.colormaps[source]

Container for colormaps that are known to Matplotlib by name.  Experimental While we expect the API to be final, we formally mark it as experimental for 3.5 because we want to keep the option to still adapt the API for 3.6 should the need arise.  The universal registry instance is matplotlib.colormaps. There should be no need for users to instantiate ColormapRegistry themselves. Read access uses a dict-like interface mapping names to Colormaps: import matplotlib as mpl
cmap = mpl.colormaps['viridis']
 Returned Colormaps are copies, so that their modification does not change the global definition of the colormap. Additional colormaps can be added via ColormapRegistry.register: mpl.colormaps.register(my_colormap)

   Miscellaneous   matplotlib.get_cachedir()[source]

Return the string path of the cache directory. The procedure used to find the directory is the same as for _get_config_dir, except using $XDG_CACHE_HOME/$HOME/.cache instead.