pylupnt.plot.Axis¶
- class pylupnt.plot.Axis(axes, *, rotate_label=None, **kwargs)¶
An Axis class for the 3D plots.
- __init__(axes, *, rotate_label=None, **kwargs)¶
- Parameters:
axes (~matplotlib.axes.Axes) – The ~.axes.Axes to which the created Axis belongs.
pickradius (float) – The acceptance radius for containment tests. See also .Axis.contains.
clear (bool, default: True) – Whether to clear the Axis on creation. This is not required, e.g., when creating an Axis as part of an Axes, as
Axes.clear
will callAxis.clear
. .. versionadded:: 3.8
- active_pane()¶
- add_callback(func)¶
Add a callback function that will be called whenever one of the .Artist’s properties changes.
- Parameters:
func (callable) –
The callback function. It must have the signature:
def func(artist: Artist) -> Any
where artist is the calling .Artist. Return values may exist but are ignored.
- Returns:
The observer id associated with the callback. This id can be used for removing the callback with .remove_callback later.
- Return type:
int
See also
- axis_date(tz=None)¶
Set up axis ticks and labels to treat data along this Axis as dates.
- Parameters:
tz (str or datetime.tzinfo, default: :rc:`timezone`) – The timezone used to create date labels.
- clear()¶
Clear the axis.
This resets axis properties to their default values:
the label
the scale
locators, formatters and ticks
major and minor grid
units
registered callbacks
- contains(mouseevent)¶
Test whether the mouse event occurred in the x-axis.
- convert_units(x)¶
- convert_xunits(x)¶
Convert x using the unit type of the xaxis.
If the artist is not contained in an Axes or if the xaxis does not have units, x itself is returned.
- convert_yunits(y)¶
Convert y using the unit type of the yaxis.
If the artist is not contained in an Axes or if the yaxis does not have units, y itself is returned.
- draw(renderer)¶
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:
renderer (~matplotlib.backend_bases.RendererBase subclass.)
Notes
This method is overridden in the Artist subclasses.
- draw_grid(renderer)¶
- draw_pane(renderer)¶
Draw pane.
- Parameters:
renderer (~matplotlib.backend_bases.RendererBase subclass)
- findobj(match=None, include_self=True)¶
Find artist objects.
Recursively find all .Artist instances contained in the artist.
- Parameters:
match –
A filter criterion for the matches. This can be
None: Return all objects contained in artist.
A function with signature
def match(artist: Artist) -> bool
. The result will only contain artists for which the function returns True.A class instance: e.g., .Line2D. The result will only contain artists of this class or its subclasses (
isinstance
check).
include_self (bool) – Include self in the list to be checked for a match.
- Return type:
list of .Artist
- format_cursor_data(data)¶
Return a string representation of data.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
The default implementation converts ints and floats and arrays of ints and floats into a comma-separated string enclosed in square brackets, unless the artist has an associated colorbar, in which case scalar values are formatted using the colorbar’s formatter.
See also
- 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_children()¶
Return a list of the child .Artists of this .Artist.
- get_clip_box()¶
Return the clipbox.
- get_clip_on()¶
Return whether the artist uses clipping.
- get_clip_path()¶
Return the clip path.
- get_cursor_data(event)¶
Return the cursor data for a given event.
Note
This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself.
Cursor data can be used by Artists to provide additional context information for a given event. The default implementation just returns None.
Subclasses can override the method and return arbitrary data. However, when doing so, they must ensure that .format_cursor_data can convert the data to a string representation.
The only current use case is displaying the z-value of an .AxesImage in the status bar of a plot window, while moving the mouse.
- Parameters:
event (~matplotlib.backend_bases.MouseEvent)
See also
- get_data_interval()¶
Return the
(min, max)
data limits of this axis.
- get_figure()¶
Return the .Figure instance the artist belongs to.
- get_gid()¶
Return the group id.
- get_gridlines()¶
Return this Axis’ grid lines as a list of .Line2Ds.
- get_in_layout()¶
Return boolean flag,
True
if artist is included in layout calculations.E.g. constrainedlayout_guide, .Figure.tight_layout(), and
fig.savefig(fname, bbox_inches='tight')
.
- get_inverted()¶
Return whether this Axis is oriented in the “inverse” direction.
The “normal” direction is increasing to the right for the x-axis and to the top for the y-axis; the “inverse” direction is increasing to the left for the x-axis and to the bottom for the y-axis.
- get_label()¶
Return the axis label as a Text instance.
- get_label_position()¶
Get the label position.
- Returns:
str – The position of the axis label.
- Return type:
{‘lower’, ‘upper’, ‘both’, ‘default’, ‘none’}
- get_label_text()¶
Get the text of the label.
- get_major_formatter()¶
Get the formatter of the major ticker.
- get_major_locator()¶
Get the locator of the major ticker.
- get_major_ticks(numticks=None)¶
Return the list of major .Ticks.
Warning
Ticks are not guaranteed to be persistent. Various operations can create, delete and modify the Tick instances. There is an imminent risk that changes to individual ticks will not survive if you work on the figure further (including also panning/zooming on a displayed figure).
Working on the individual ticks is a method of last resort. Use .set_tick_params instead if possible.
- get_majorticklabels()¶
Return this Axis’ major tick labels, as a list of ~.text.Text.
- get_majorticklines()¶
Return this Axis’ major tick lines as a list of .Line2Ds.
- get_majorticklocs()¶
Return this Axis’ major tick locations in data coordinates.
- get_minor_formatter()¶
Get the formatter of the minor ticker.
- get_minor_locator()¶
Get the locator of the minor ticker.
- get_minor_ticks(numticks=None)¶
Return the list of minor .Ticks.
Warning
Ticks are not guaranteed to be persistent. Various operations can create, delete and modify the Tick instances. There is an imminent risk that changes to individual ticks will not survive if you work on the figure further (including also panning/zooming on a displayed figure).
Working on the individual ticks is a method of last resort. Use .set_tick_params instead if possible.
- get_minorticklabels()¶
Return this Axis’ minor tick labels, as a list of ~.text.Text.
- get_minorticklines()¶
Return this Axis’ minor tick lines as a list of .Line2Ds.
- get_minorticklocs()¶
Return this Axis’ minor tick locations in data coordinates.
- get_minpos()¶
- get_mouseover()¶
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
- get_offset_text()¶
Return the axis offsetText as a Text instance.
- get_path_effects()¶
- get_picker()¶
Return the picking behavior of the artist.
The possible values are described in .Artist.set_picker.
See also
Artist.set_picker
,Artist.pickable
,Artist.pick
- get_pickradius()¶
Return the depth of the axis used by the picker.
- get_rasterized()¶
Return whether the artist is to be rasterized.
- get_remove_overlapping_locs()¶
- get_rotate_label(text)¶
- get_scale()¶
Return this Axis’ scale (as a str).
- get_sketch_params()¶
Return the sketch parameters for the artist.
- Returns:
A 3-tuple with the following elements:
scale: The amplitude of the wiggle perpendicular to the source line.
length: The length of the wiggle along the line.
randomness: The scale factor by which the length is shrunken or expanded.
Returns None if no sketch parameters were set.
- Return type:
tuple or None
- get_snap()¶
Return the snap setting.
See .set_snap for details.
- get_tick_padding()¶
- get_tick_params(which='major')¶
Get appearance parameters for ticks, ticklabels, and gridlines.
Added in version 3.7.
- Parameters:
which ({'major', 'minor'}, default: 'major') – The group of ticks for which the parameters are retrieved.
- Returns:
Properties for styling tick elements added to the axis.
- Return type:
dict
Notes
This method returns the appearance parameters for styling new elements added to this axis and may be different from the values on current elements if they were modified directly by the user (e.g., via
set_*
methods on individual tick objects).Examples
>>> ax.yaxis.set_tick_params(labelsize=30, labelcolor='red', ... direction='out', which='major') >>> ax.yaxis.get_tick_params(which='major') {'direction': 'out', 'left': True, 'right': False, 'labelleft': True, 'labelright': False, 'gridOn': False, 'labelsize': 30, 'labelcolor': 'red'} >>> ax.yaxis.get_tick_params(which='minor') {'left': True, 'right': False, 'labelleft': True, 'labelright': False, 'gridOn': False}
- get_tick_space()¶
Return the estimated number of ticks that can fit on the axis.
- get_ticklabels(minor=False, which=None)¶
Get this Axis’ tick labels.
- Parameters:
minor (bool) – Whether to return the minor or the major ticklabels.
which (None, ('minor', 'major', 'both')) –
Overrides minor.
Selects which ticklabels to return
- Return type:
list of ~matplotlib.text.Text
- get_ticklines(minor=False)¶
Return this Axis’ tick lines as a list of .Line2Ds.
- get_ticklocs(*, minor=False)¶
Return this Axis’ tick locations in data coordinates.
The locations are not clipped to the current axis limits and hence may contain locations that are not visible in the output.
- Parameters:
minor (bool, default: False) – True to return the minor tick directions, False to return the major tick directions.
- Return type:
array of tick locations
- get_ticks_direction(minor=False)¶
Return an array of this Axis’ tick directions.
- Parameters:
minor (bool, default: False) – True to return the minor tick directions, False to return the major tick directions.
- Return type:
array of tick directions
- get_ticks_position()¶
Get the ticks position.
- Returns:
str – The position of the bolded axis lines, ticks, and tick labels.
- Return type:
{‘lower’, ‘upper’, ‘both’, ‘default’, ‘none’}
- get_tightbbox(renderer=None, *, for_layout_only=False)¶
Return a bounding box that encloses the axis. It only accounts tick labels, axis label, and offsetText.
If for_layout_only is True, then the width of the label (if this is an x-axis) or the height of the label (if this is a y-axis) is collapsed to near zero. This allows tight/constrained_layout to ignore too-long labels when doing their layout.
- get_transform()¶
Return the transform used in the Axis’ scale
- 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_units()¶
Return the units for axis.
- get_url()¶
Return the url.
- get_view_interval()¶
Return the
(min, max)
view limits of this axis.
- get_visible()¶
Return the visibility.
- get_window_extent(renderer=None)¶
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_zorder()¶
Return the artist’s zorder.
- grid(visible=None, which='major', **kwargs)¶
Configure the grid lines.
- Parameters:
visible (bool or None) –
Whether to show the grid lines. If any kwargs are supplied, it is assumed you want the grid on and visible will be set to True.
If visible is None and there are no kwargs, this toggles the visibility of the lines.
which ({'major', 'minor', 'both'}) – The grid lines to apply the changes on.
**kwargs (~matplotlib.lines.Line2D properties) –
Define the line properties of the grid, e.g.:
grid(color='r', linestyle='-', linewidth=2)
- have_units()¶
Return whether units are set on any axis.
- init3d()¶
[Deprecated]
Notes
Deprecated since version 3.6:
- is_transform_set()¶
Return whether the Artist has an explicitly set transform.
This is True after .set_transform has been called.
- limit_range_for_scale(vmin, vmax)¶
- minorticks_off()¶
Remove minor ticks from the Axis.
- minorticks_on()¶
Display default minor ticks on the Axis, depending on the scale (~.axis.Axis.get_scale).
Scales use specific minor locators:
log: ~.LogLocator
symlog: ~.SymmetricalLogLocator
asinh: ~.AsinhLocator
logit: ~.LogitLocator
default: ~.AutoMinorLocator
Displaying minor ticks may reduce performance; you may turn them off using minorticks_off() if drawing speed is a problem.
- pchanged()¶
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
- pick(mouseevent)¶
Process a pick event.
Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.
See also
Artist.set_picker
,Artist.get_picker
,Artist.pickable
- pickable()¶
Return whether the artist is pickable.
See also
Artist.set_picker
,Artist.get_picker
,Artist.pick
- properties()¶
Return a dictionary of all the properties of the artist.
- remove()¶
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with .FigureCanvasBase.draw_idle. Call ~.axes.Axes.relim to update the Axes limits if desired.
Note: ~.axes.Axes.relim will not see collections even if the collection was added to the Axes with autolim = True.
Note: there is no support for removing the artist’s legend entry.
- remove_callback(oid)¶
Remove a callback based on its observer id.
See also
- reset_ticks()¶
Re-initialize the major and minor Tick lists.
Each list starts with a single fresh Tick.
- set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, data_interval=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, inverted=<UNSET>, label=<UNSET>, label_coords=<UNSET>, label_position=<UNSET>, label_text=<UNSET>, major_formatter=<UNSET>, major_locator=<UNSET>, minor_formatter=<UNSET>, minor_locator=<UNSET>, mouseover=<UNSET>, pane_color=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, pickradius=<UNSET>, rasterized=<UNSET>, remove_overlapping_locs=<UNSET>, rotate_label=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, tick_params=<UNSET>, ticklabels=<UNSET>, ticks=<UNSET>, ticks_position=<UNSET>, transform=<UNSET>, units=<UNSET>, url=<UNSET>, view_interval=<UNSET>, visible=<UNSET>, zorder=<UNSET>)¶
Set multiple properties at once.
Supported properties are
- 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 clip_box: ~matplotlib.transforms.BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None data_interval: unknown figure: ~matplotlib.figure.Figure gid: str in_layout: bool inverted: unknown label: object label_coords: unknown label_position: {‘lower’, ‘upper’, ‘both’, ‘default’, ‘none’} label_text: str major_formatter: ~matplotlib.ticker.Formatter,
str
, or function major_locator: ~matplotlib.ticker.Locator minor_formatter: ~matplotlib.ticker.Formatter,str
, or function minor_locator: ~matplotlib.ticker.Locator mouseover: bool pane_color: :mpltype:`color` path_effects: list of .AbstractPathEffect picker: None or bool or float or callable pickradius: float rasterized: bool remove_overlapping_locs: unknown rotate_label: unknown sketch_params: (scale: float, length: float, randomness: float) snap: bool or None tick_params: unknown ticklabels: sequence of str or of .Texts ticks: 1D array-like ticks_position: {‘lower’, ‘upper’, ‘both’, ‘default’, ‘none’} transform: ~matplotlib.transforms.Transform units: units tag url: str view_interval: unknown visible: bool zorder: float
- set_agg_filter(filter_func)¶
Set the agg filter.
- Parameters:
filter_func (callable) –
A filter function, which takes a (m, n, depth) float array and a dpi value, and returns a (m, n, depth) array and two offsets from the bottom left corner of the image
- set_alpha(alpha)¶
Set the alpha value used for blending - not supported on all backends.
- Parameters:
alpha (scalar or None) – alpha must be within the 0-1 range, inclusive.
- set_animated(b)¶
Set whether the artist is intended to be used in an animation.
If True, the artist is excluded from regular drawing of the figure. You have to call .Figure.draw_artist / .Axes.draw_artist explicitly on the artist. This approach is used to speed up animations using blitting.
See also matplotlib.animation and blitting.
- Parameters:
b (bool)
- set_clip_box(clipbox)¶
Set the artist’s clip .Bbox.
- Parameters:
clipbox (~matplotlib.transforms.BboxBase or None) – Will typically be created from a .TransformedBbox. For instance,
TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)
is the default clipping for an artist added to an Axes.
- set_clip_on(b)¶
Set whether the artist uses clipping.
When False, artists will be visible outside the Axes which can lead to unexpected results.
- Parameters:
b (bool)
- set_clip_path(path, transform=None)¶
Set the artist’s clip path.
- Parameters:
path (~matplotlib.patches.Patch or .Path or .TransformedPath or None) – The clip path. If given a .Path, transform must be provided as well. If None, a previously set clip path is removed.
transform (~matplotlib.transforms.Transform, optional) – Only used if path is a .Path, in which case the given .Path is converted to a .TransformedPath using transform.
Notes
For efficiency, if path is a .Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to
None
.For technical reasons (support of ~.Artist.set), a tuple (path, transform) is also accepted as a single positional parameter.
- set_data_interval(vmin, vmax, ignore=False)¶
Set the axis data limits. This method is for internal use.
If ignore is False (the default), this method will never reduce the preexisting data limits, only expand them if vmin or vmax are not within them. Moreover, the order of vmin and vmax does not matter; the orientation of the axis will not change.
If ignore is True, the data limits will be set exactly to
(vmin, vmax)
in that order.
- set_default_intervals()¶
Set the default limits for the axis data and view interval if they have not been not mutated yet.
- set_figure(fig)¶
Set the .Figure instance the artist belongs to.
- Parameters:
fig (~matplotlib.figure.Figure)
- set_gid(gid)¶
Set the (group) id for the artist.
- Parameters:
gid (str)
- set_in_layout(in_layout)¶
Set if artist is to be included in layout calculations, E.g. constrainedlayout_guide, .Figure.tight_layout(), and
fig.savefig(fname, bbox_inches='tight')
.- Parameters:
in_layout (bool)
- set_inverted(inverted)¶
Set whether this Axis is oriented in the “inverse” direction.
The “normal” direction is increasing to the right for the x-axis and to the top for the y-axis; the “inverse” direction is increasing to the left for the x-axis and to the bottom for the y-axis.
- set_label(s)¶
Set a label that will be displayed in the legend.
- Parameters:
s (object) – s will be converted to a string by calling str.
- set_label_coords(x, y, transform=None)¶
Set the coordinates of the label.
By default, the x coordinate of the y label and the y coordinate of the x label are determined by the tick label bounding boxes, but this can lead to poor alignment of multiple labels if there are multiple Axes.
You can also specify the coordinate system of the label with the transform. If None, the default coordinate system will be the axes coordinate system: (0, 0) is bottom left, (0.5, 0.5) is center, etc.
- set_label_position(position)¶
Set the label position.
- Parameters:
position ({'lower', 'upper', 'both', 'default', 'none'}) – The position of the axis label.
- set_label_text(label, fontdict=None, **kwargs)¶
Set the text value of the axis label.
- Parameters:
label (str) – Text string.
fontdict (dict) –
Text properties.
Discouraged
The use of fontdict is discouraged. Parameters should be passed as individual keyword arguments or using dictionary-unpacking
set_label_text(..., **fontdict)
.**kwargs – Merged into fontdict.
- set_major_formatter(formatter)¶
Set the formatter of the major ticker.
In addition to a ~matplotlib.ticker.Formatter instance, this also accepts a
str
or function.For a
str
a ~matplotlib.ticker.StrMethodFormatter is used. The field used for the value must be labeled'x'
and the field used for the position must be labeled'pos'
. See the ~matplotlib.ticker.StrMethodFormatter documentation for more information.For a function, a ~matplotlib.ticker.FuncFormatter is used. The function must take two inputs (a tick value
x
and a positionpos
), and return a string containing the corresponding tick label. See the ~matplotlib.ticker.FuncFormatter documentation for more information.- Parameters:
formatter (~matplotlib.ticker.Formatter,
str
, or function)
- set_major_locator(locator)¶
Set the locator of the major ticker.
- Parameters:
locator (~matplotlib.ticker.Locator)
- set_minor_formatter(formatter)¶
Set the formatter of the minor ticker.
In addition to a ~matplotlib.ticker.Formatter instance, this also accepts a
str
or function. See .Axis.set_major_formatter for more information.- Parameters:
formatter (~matplotlib.ticker.Formatter,
str
, or function)
- set_minor_locator(locator)¶
Set the locator of the minor ticker.
- Parameters:
locator (~matplotlib.ticker.Locator)
- set_mouseover(mouseover)¶
Set whether this artist is queried for custom context information when the mouse cursor moves over it.
- Parameters:
mouseover (bool)
See also
get_cursor_data
,ToolCursorPosition
,NavigationToolbar2
- set_pane_color(color, alpha=None)¶
Set pane color.
- Parameters:
color (:mpltype:`color`) – Color for axis pane.
alpha (float, optional) – Alpha value for axis pane. If None, base it on color.
- set_path_effects(path_effects)¶
Set the path effects.
- Parameters:
path_effects (list of .AbstractPathEffect)
- set_picker(picker)¶
Define the picking behavior of the artist.
- Parameters:
picker (None or bool or float or callable) –
This can be one of the following:
None: Picking is disabled for this artist (default).
A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.
A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.
- set_pickradius(pickradius)¶
Set the depth of the axis used by the picker.
- Parameters:
pickradius (float) – The acceptance radius for containment tests. See also .Axis.contains.
- set_rasterized(rasterized)¶
Force rasterized (bitmap) drawing for vector graphics output.
Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued.
This setting is ignored for pixel-based output.
See also /gallery/misc/rasterization_demo.
- Parameters:
rasterized (bool)
- set_remove_overlapping_locs(val)¶
- set_rotate_label(val)¶
Whether to rotate the axis label: True, False or None. If set to None the label will be rotated if longer than 4 chars.
- set_sketch_params(scale=None, length=None, randomness=None)¶
Set the sketch parameters.
- Parameters:
scale (float, optional) – The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.
length (float, optional) – The length of the wiggle along the line, in pixels (default 128.0)
randomness (float, optional) –
The scale factor by which the length is shrunken or expanded (default 16.0)
The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.
- set_snap(snap)¶
Set the snapping behavior.
Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.
Snapping is currently only supported by the Agg and MacOSX backends.
- Parameters:
snap (bool or None) –
Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.
- set_tick_params(which='major', reset=False, **kwargs)¶
Set appearance parameters for ticks, ticklabels, and gridlines.
For documentation of keyword arguments, see
matplotlib.axes.Axes.tick_params()
.See also
Axis.get_tick_params
View the current style settings for ticks, ticklabels, and gridlines.
- set_ticklabels(labels, *, minor=False, fontdict=None, **kwargs)¶
[Discouraged] Set this Axis’ tick labels with list of string labels.
Discouraged
The use of this method is discouraged, because of the dependency on tick positions. In most cases, you’ll want to use
Axes.set_[x/y/z]ticks(positions, labels)
orAxis.set_ticks
instead.If you are using this method, you should always fix the tick positions before, e.g. by using .Axis.set_ticks or by explicitly setting a ~.ticker.FixedLocator. Otherwise, ticks are free to move and the labels may end up in unexpected positions.
- Parameters:
labels (sequence of str or of .Texts) – Texts for labeling each tick location in the sequence set by .Axis.set_ticks; the number of labels must match the number of locations. The labels are used as is, via a .FixedFormatter (without further formatting).
minor (bool) – If True, set minor ticks instead of major ticks.
fontdict (dict, optional) –
Discouraged
The use of fontdict is discouraged. Parameters should be passed as individual keyword arguments or using dictionary-unpacking
set_ticklabels(..., **fontdict)
.A dictionary controlling the appearance of the ticklabels. The default fontdict is:
{'fontsize': rcParams['axes.titlesize'], 'fontweight': rcParams['axes.titleweight'], 'verticalalignment': 'baseline', 'horizontalalignment': loc}
**kwargs –
Text properties.
Warning
This only sets the properties of the current ticks, which is only sufficient for static plots.
Ticks are not guaranteed to be persistent. Various operations can create, delete and modify the Tick instances. There is an imminent risk that these settings can get lost if you work on the figure further (including also panning/zooming on a displayed figure).
Use .set_tick_params instead if possible.
- Returns:
For each tick, includes
tick.label1
if it is visible, thentick.label2
if it is visible, in that order.- Return type:
list of .Texts
- set_ticks(ticks, labels=None, *, minor=False, **kwargs)¶
Set this Axis’ tick locations and optionally tick labels.
If necessary, the view limits of the Axis are expanded so that all given ticks are visible.
- Parameters:
ticks (1D array-like) –
Array of tick locations (either floats or in axis units). The axis .Locator is replaced by a ~.ticker.FixedLocator.
Pass an empty list (
set_ticks([])
) to remove all ticks.Some tick formatters will not label arbitrary tick positions; e.g. log formatters only label decade ticks by default. In such a case you can set a formatter explicitly on the axis using .Axis.set_major_formatter or provide formatted labels yourself.
labels (list of str, optional) – Tick labels for each location in ticks; must have the same length as ticks. If set, the labels are used as is, via a .FixedFormatter. If not set, the labels are generated using the axis tick .Formatter.
minor (bool, default: False) – If
False
, set only the major ticks; ifTrue
, only the minor ticks.**kwargs – .Text properties for the labels. Using these is only allowed if you pass labels. In other cases, please use ~.Axes.tick_params.
Notes
The mandatory expansion of the view limits is an intentional design choice to prevent the surprise of a non-visible tick. If you need other limits, you should set the limits explicitly after setting the ticks.
- set_ticks_position(position)¶
Set the ticks position.
- Parameters:
position ({'lower', 'upper', 'both', 'default', 'none'}) – The position of the bolded axis lines, ticks, and tick labels.
- set_transform(t)¶
Set the artist transform.
- Parameters:
t (~matplotlib.transforms.Transform)
- set_units(u)¶
Set the units for axis.
- Parameters:
u (units tag)
Notes
The units of any shared axis will also be updated.
- set_url(url)¶
Set the url for the artist.
- Parameters:
url (str)
- set_view_interval(vmin, vmax, ignore=False)¶
Set the axis view limits. This method is for internal use; Matplotlib users should typically use e.g. ~.Axes.set_xlim or ~.Axes.set_ylim.
If ignore is False (the default), this method will never reduce the preexisting view limits, only expand them if vmin or vmax are not within them. Moreover, the order of vmin and vmax does not matter; the orientation of the axis will not change.
If ignore is True, the view limits will be set exactly to
(vmin, vmax)
in that order.
- set_visible(b)¶
Set the artist’s visibility.
- Parameters:
b (bool)
- set_zorder(level)¶
Set the zorder for the artist. Artists with lower zorder values are drawn first.
- Parameters:
level (float)
- tick_bottom()¶
Move ticks and ticklabels (if present) to the bottom of the Axes.
- tick_top()¶
Move ticks and ticklabels (if present) to the top of the Axes.
- update(props)¶
Update this artist’s properties from the dict props.
- Parameters:
props (dict)
- update_from(other)¶
Copy properties from other to self.
- update_units(data)¶
Introspect data for units converter and update the
axis.converter
instance if necessary. Return True if data is registered for unit conversion.
- OFFSETTEXTPAD = 3¶
- property adir¶
[Deprecated]
Notes
Deprecated since version 3.6:
- property axes¶
The ~.axes.Axes instance the artist resides in, or None.
- axis_name = 'x'¶
Read-only name identifying the axis.
- property d_interval¶
[Deprecated]
Notes
Deprecated since version 3.6: Use get_data_interval instead.
- property isDefault_majfmt¶
- property isDefault_majloc¶
- property isDefault_minfmt¶
- property isDefault_minloc¶
- majorTicks¶
A descriptor for lazy instantiation of tick lists.
See comment above definition of the
majorTicks
andminorTicks
attributes.
- minorTicks¶
A descriptor for lazy instantiation of tick lists.
See comment above definition of the
majorTicks
andminorTicks
attributes.
- property mouseover¶
Return whether this artist is queried for custom context information when the mouse cursor moves over it.
- property pickradius¶
The acceptance radius for containment tests. See also .Axis.contains.
- property remove_overlapping_locs¶
If minor ticker locations that overlap with major ticker locations should be trimmed.
- property stale¶
Whether the artist is ‘stale’ and needs to be re-drawn for the output to match the internal state of the artist.
- property sticky_edges¶
x
andy
sticky edge lists for autoscaling.When performing autoscaling, if a data limit coincides with a value in the corresponding sticky_edges list, then no margin will be added–the view limit “sticks” to the edge. A typical use case is histograms, where one usually expects no margin on the bottom edge (0) of the histogram.
Moreover, margin expansion “bumps” against sticky edges and cannot cross them. For example, if the upper data limit is 1.0, the upper view limit computed by simple margin application is 1.2, but there is a sticky edge at 1.1, then the actual upper view limit will be 1.1.
This attribute cannot be assigned to; however, the
x
andy
lists can be modified in place as needed.Examples
>>> artist.sticky_edges.x[:] = (xmin, xmax) >>> artist.sticky_edges.y[:] = (ymin, ymax)
- property v_interval¶
[Deprecated]
Notes
Deprecated since version 3.6: Use get_view_interval instead.
- zorder = 0¶