WrightTools.artists.Figure

class WrightTools.artists.Figure(figsize=None, dpi=None, *, facecolor=None, edgecolor=None, linewidth=0.0, frameon=None, subplotpars=None, tight_layout=None, constrained_layout=None, layout=None, **kwargs)[source]

Figure.

__init__(figsize=None, dpi=None, *, facecolor=None, edgecolor=None, linewidth=0.0, frameon=None, subplotpars=None, tight_layout=None, constrained_layout=None, layout=None, **kwargs)[source]
Parameters:
  • figsize (2-tuple of floats, default: :rc:`figure.figsize`) – Figure dimension (width, height) in inches.

  • dpi (float, default: :rc:`figure.dpi`) – Dots per inch.

  • facecolor (default: :rc:`figure.facecolor`) – The figure patch facecolor.

  • edgecolor (default: :rc:`figure.edgecolor`) – The figure patch edge color.

  • linewidth (float) – The linewidth of the frame (i.e. the edge linewidth of the figure patch).

  • frameon (bool, default: :rc:`figure.frameon`) – If False, suppress drawing the figure background patch.

  • subplotpars (SubplotParams) – Subplot parameters. If not given, the default subplot parameters :rc:`figure.subplot.*` are used.

  • tight_layout (bool or dict, default: :rc:`figure.autolayout`) –

    Whether to use the tight layout mechanism. See .set_tight_layout.

    Discouraged

    The use of this parameter is discouraged. Please use layout='tight' instead for the common case of tight_layout=True and use .set_tight_layout otherwise.

  • constrained_layout (bool, default: :rc:`figure.constrained_layout.use`) –

    This is equal to layout='constrained'.

    Discouraged

    The use of this parameter is discouraged. Please use layout='constrained' instead.

  • layout ({‘constrained’, ‘compressed’, ‘tight’, ‘none’, .LayoutEngine, None}, default: None) –

    The layout mechanism for positioning of plot elements to avoid overlapping Axes decorations (labels, ticks, etc). Note that layout managers can have significant performance penalties.

    • ’constrained’: The constrained layout solver adjusts axes sizes to avoid overlapping axes decorations. Can handle complex plot layouts and colorbars, and is thus recommended.

      See Constrained layout guide for examples.

    • ’compressed’: uses the same algorithm as ‘constrained’, but removes extra space between fixed-aspect-ratio Axes. Best for simple grids of axes.

    • ’tight’: Use the tight layout mechanism. This is a relatively simple algorithm that adjusts the subplot parameters so that decorations do not overlap.

      See Tight layout guide for examples.

    • ’none’: Do not use a layout engine.

    • A .LayoutEngine instance. Builtin layout classes are .ConstrainedLayoutEngine and .TightLayoutEngine, more easily accessible by ‘constrained’ and ‘tight’. Passing an instance allows third parties to provide their own layout engine.

    If not given, fall back to using the parameters tight_layout and constrained_layout, including their config defaults :rc:`figure.autolayout` and :rc:`figure.constrained_layout.use`.

  • **kwargs (.Figure properties, optional) – Properties: agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: scalar or None animated: bool canvas: FigureCanvas clip_box: ~matplotlib.transforms.BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None constrained_layout: unknown constrained_layout_pads: unknown dpi: float edgecolor: color facecolor: color figheight: float figure: ~matplotlib.figure.Figure figwidth: float frameon: bool gid: str in_layout: bool label: object layout_engine: {‘constrained’, ‘compressed’, ‘tight’, ‘none’, .LayoutEngine, None} linewidth: number mouseover: bool path_effects: list of .AbstractPathEffect picker: None or bool or float or callable rasterized: bool size_inches: (float, float) or float sketch_params: (scale: float, length: float, randomness: float) snap: bool or None tight_layout: unknown transform: ~matplotlib.transforms.Transform url: str visible: bool zorder: float

Methods

__init__([figsize, dpi, facecolor, ...])

param figsize:

Figure dimension (width, height) in inches.

add_artist(artist[, clip])

Add an .Artist to the figure.

add_axes(*args, **kwargs)

Add an ~.axes.Axes to the figure.

add_axobserver(func)

Whenever the Axes state change, func(self) will be called.

add_callback(func)

Add a callback function that will be called whenever one of the .Artist's properties changes.

add_gridspec([nrows, ncols])

Return a .GridSpec that has this figure as a parent.

add_subfigure(subplotspec, **kwargs)

Add a .SubFigure to the figure as part of a subplot arrangement.

add_subplot(*args, **kwargs)

Add a subplot to the figure.

align_labels([axs])

Align the xlabels and ylabels of subplots with the same subplots row or column (respectively) if label alignment is being done automatically (i.e. the label position is not manually set).

align_xlabels([axs])

Align the xlabels of subplots in the same subplot column if label alignment is being done automatically (i.e. the label position is not manually set).

align_ylabels([axs])

Align the ylabels of subplots in the same subplot column if label alignment is being done automatically (i.e. the label position is not manually set).

autofmt_xdate([bottom, rotation, ha, which])

Date ticklabels often overlap, so it is useful to rotate them and right align them.

clear([keep_observers])

Clear the figure.

clf([keep_observers])

[Discouraged] Alias for the clear() method.

colorbar(mappable[, cax, ax, use_gridspec])

Add a colorbar to a plot.

contains(mouseevent)

Test whether the mouse event occurred on the figure.

convert_xunits(x)

Convert x using the unit type of the xaxis.

convert_yunits(y)

Convert y using the unit type of the yaxis.

delaxes(ax)

Remove the ~.axes.Axes ax from the figure; update the current Axes.

draw(renderer)

Draw the Artist (and its children) using the given renderer.

draw_artist(a)

Draw .Artist a only.

draw_without_rendering()

Draw the figure with no output.

figimage(X[, xo, yo, alpha, norm, cmap, ...])

Add a non-resampled image to the figure.

findobj([match, include_self])

Find artist objects.

format_cursor_data(data)

Return a string representation of data.

gca()

Get the current Axes.

get_agg_filter()

Return filter function to be used for agg filter.

get_alpha()

Return the alpha value used for blending - not supported on all backends.

get_animated()

Return whether the artist is animated.

get_axes()

List of Axes in the Figure.

get_children()

Get a list of artists contained in the figure.

get_clip_box()

Return the clipbox.

get_clip_on()

Return whether the artist uses clipping.

get_clip_path()

Return the clip path.

get_constrained_layout()

Return whether constrained layout is being used.

get_constrained_layout_pads([relative])

[Deprecated] Get padding for constrained_layout.

get_cursor_data(event)

Return the cursor data for a given event.

get_default_bbox_extra_artists()

get_dpi()

Return the resolution in dots per inch as a float.

get_edgecolor()

Get the edge color of the Figure rectangle.

get_facecolor()

Get the face color of the Figure rectangle.

get_figheight()

Return the figure height in inches.

get_figure()

Return the .Figure instance the artist belongs to.

get_figwidth()

Return the figure width in inches.

get_frameon()

Return the figure's background patch visibility, i.e. whether the figure background will be drawn.

get_gid()

Return the group id.

get_in_layout()

Return boolean flag, True if artist is included in layout calculations.

get_label()

Return the label used for this artist in the legend.

get_layout_engine()

get_linewidth()

Get the line width of the Figure rectangle.

get_mouseover()

Return whether this artist is queried for custom context information when the mouse cursor moves over it.

get_path_effects()

get_picker()

Return the picking behavior of the artist.

get_rasterized()

Return whether the artist is to be rasterized.

get_size_inches()

Return the current size of the figure in inches.

get_sketch_params()

Return the sketch parameters for the artist.

get_snap()

Return the snap setting.

get_suptitle()

Return the suptitle as string or an empty string if not set.

get_supxlabel()

Return the supxlabel as string or an empty string if not set.

get_supylabel()

Return the supylabel as string or an empty string if not set.

get_tight_layout()

Return whether .tight_layout is called when drawing.

get_tightbbox([renderer, bbox_extra_artists])

Return a (tight) bounding box of the figure in inches.

get_transform()

Return the .Transform instance used by this artist.

get_transformed_clip_path_and_affine()

Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.

get_url()

Return the url.

get_visible()

Return the visibility.

get_window_extent([renderer])

Get the artist's bounding box in display space.

get_zorder()

Return the artist's zorder.

ginput([n, timeout, show_clicks, mouse_add, ...])

Blocking call to interact with a figure.

have_units()

Return whether units are set on any axis.

is_transform_set()

Return whether the Artist has an explicitly set transform.

legend(*args, **kwargs)

Place a legend on the figure.

pchanged()

Call all of the registered callbacks.

pick(mouseevent)

Process a pick event.

pickable()

Return whether the artist is pickable.

properties()

Return a dictionary of all the properties of the artist.

remove()

Remove the artist from the figure if possible.

remove_callback(oid)

Remove a callback based on its observer id.

savefig(fname, *[, transparent])

Save the current figure.

sca(a)

Set the current Axes to be a and return a.

set(*[, agg_filter, alpha, animated, ...])

Set multiple properties at once.

set_agg_filter(filter_func)

Set the agg filter.

set_alpha(alpha)

Set the alpha value used for blending - not supported on all backends.

set_animated(b)

Set whether the artist is intended to be used in an animation.

set_canvas(canvas)

Set the canvas that contains the figure

set_clip_box(clipbox)

Set the artist's clip .Bbox.

set_clip_on(b)

Set whether the artist uses clipping.

set_clip_path(path[, transform])

Set the artist's clip path.

set_constrained_layout(constrained)

[Deprecated] Set whether constrained_layout is used upon drawing.

set_constrained_layout_pads(**kwargs)

[Deprecated] Set padding for constrained_layout.

set_dpi(val)

Set the resolution of the figure in dots-per-inch.

set_edgecolor(color)

Set the edge color of the Figure rectangle.

set_facecolor(color)

Set the face color of the Figure rectangle.

set_figheight(val[, forward])

Set the height of the figure in inches.

set_figure(fig)

Set the .Figure instance the artist belongs to.

set_figwidth(val[, forward])

Set the width of the figure in inches.

set_frameon(b)

Set the figure's background patch visibility, i.e. whether the figure background will be drawn.

set_gid(gid)

Set the (group) id for the artist.

set_in_layout(in_layout)

Set if artist is to be included in layout calculations, E.g.

set_label(s)

Set a label that will be displayed in the legend.

set_layout_engine([layout])

Set the layout engine for this figure.

set_linewidth(linewidth)

Set the line width of the Figure rectangle.

set_mouseover(mouseover)

Set whether this artist is queried for custom context information when the mouse cursor moves over it.

set_path_effects(path_effects)

Set the path effects.

set_picker(picker)

Define the picking behavior of the artist.

set_rasterized(rasterized)

Force rasterized (bitmap) drawing for vector graphics output.

set_size_inches(w[, h, forward])

Set the figure size in inches.

set_sketch_params([scale, length, randomness])

Set the sketch parameters.

set_snap(snap)

Set the snapping behavior.

set_tight_layout(tight)

[Deprecated] Set whether and how .tight_layout is called when drawing.

set_transform(t)

Set the artist transform.

set_url(url)

Set the url for the artist.

set_visible(b)

Set the artist's visibility.

set_zorder(level)

Set the zorder for the artist.

show([warn])

If using a GUI backend with pyplot, display the figure window.

subfigures([nrows, ncols, squeeze, wspace, ...])

Add a set of subfigures to this figure or subfigure.

subplot_mosaic(mosaic, *[, sharex, sharey, ...])

Build a layout of Axes based on ASCII art or nested lists.

subplots([nrows, ncols, sharex, sharey, ...])

Add a set of subplots to this figure.

subplots_adjust([left, bottom, right, top, ...])

Adjust the subplot layout parameters.

suptitle(t, **kwargs)

Add a centered suptitle to the figure.

supxlabel(t, **kwargs)

Add a centered supxlabel to the figure.

supylabel(t, **kwargs)

Add a centered supylabel to the figure.

text(x, y, s[, fontdict])

Add text to figure.

tight_layout(*[, pad, h_pad, w_pad, rect])

Adjust the padding between and around subplots.

update(props)

Update this artist's properties from the dict props.

update_from(other)

Copy properties from other to self.

waitforbuttonpress([timeout])

Blocking call to interact with the figure.

Attributes

axes

List of Axes in the Figure.

dpi

The resolution in dots per inch.

frameon

Return the figure's background patch visibility, i.e. whether the figure background will be drawn.

mouseover

Return whether this artist is queried for custom context information when the mouse cursor moves over it.

stale

Whether the artist is 'stale' and needs to be re-drawn for the output to match the internal state of the artist.

sticky_edges

x and y sticky edge lists for autoscaling.

zorder