clearplot.axes module

class Axes(fig, **kwargs)

Bases: clearplot.axes._Data_Axes_Base

A generic axes class to plot data on.

__init__(fig, **kwargs)

Instantiates a generic axes object to plot data on.

Parameters:
  • fig (figure object) – Figure to place the axes in.
  • position (1x2 numpy array, optional) – Position of axes in mm from the lower left corner of the figure.
  • size (1x2 numpy array, optional) – Width and height of axes in mm.
  • scale_plot (float, optional) – Scales distances between different objects associated with the axes
  • font_size (float, optional) – Font size of text associated with the axes
  • share_x_ax (axes object, optional) – Share the x axis with a different set of axes to create a plot with two y axes.
  • share_y_ax (axes object, optional) – Share the y axis with a different set of axes to create a plot with two x axes.
  • link_x_ax (axes object, optional) – Link the x axis with a different set of axes. The linked x axes will be constrained to have the same limits and tick mark spacings. By default, the new axes will be placed above the original axes.
  • link_y_ax (axes object, optional) – Link the y axis with a different set of axes. The linked x axes will be constrained to have the same limits and tick mark spacings. By default, the new axes will be placed to the right of the original axes.
add_arrow(style_str, x, cs, orient, length, head_length=7.0, head_aspect_ratio=3.0, color=[0, 0, 0])

Creates an arrow with a curved back. The arrow can be placed relative to several coordinate systems, yet it retains it’s shape, even when the data limits, axes, or figure window change size.

Parameters:
  • x (1x2 numpy array) – Tip of arrowhead, in the coordinate system(s) specified in x_coord_sys
  • cs (string or 1x2 list) – Specifies the coordinate system for the coordinates in x. See description of cs_1 in the axes.annotate method for further information.
  • orient (float) – Orientation angle (rad) of arrow
  • length (float, optional) – Length of the arrow, in mm
  • = float, optional (head_length) – Length of the arrowhead
  • head_aspect_ratio (float, optional) – Length/width ratio of the arrowhead
  • color (1x3 list, optional) – RGB value for the arrow
Returns:

arrow

Return type:

annotation object

add_arrowhead(x, cs, orient, length=7.0, aspect_ratio=2.5, color=[0, 0, 0])

Creates an arrowhead with a curved back. The arrow can be placed relative to several coordinate systems, yet it retains it’s shape, even when the data limits, axes, or figure window change size.

Parameters:
  • x (1x2 numpy array) – Tip of arrowhead, in the coordinate system(s) specified in x_coord_sys
  • cs (string or 1x2 list) – Specifies the coordinate system for the coordinates in x. See description of cs_1 in the axes.annotate method for further information.
  • orient (float) – Orientation angle (rad) of arrowhead
  • length (float, optional) – Length of the arrowhead, in mm
  • aspect_ratio (float, optional) – Length/width ratio of the arrowhead
  • color (1x3 list, optional) – RGB value for the arrowhead
Returns:

arrowhead

Return type:

annotation object

add_arrowheads_to_curves(**kwargs)

Adds arrowheads to curves showing the direction of the curves

Parameters:
  • ndx (list of lists or numpy array, optional) – Specifies the index along the curve to place the tip of the arrowhead. If there are M curves and you want N arrowheads on each curves, input a MxN array of indices.
  • length (float, optional) – Arrowhead length from tip to tail
  • color (1x3 list, optional) – Arrowhead RGB color
  • pick (bool, optional) – Specifies whether or not to manually pick the arrow positions
add_circle(x, r, cs='axes mm', **kwargs)

Adds a circle to the axes

Parameters:
  • x (1x2 numpy array) – Coordinates of the circle center. The coordinate system is specified in cs.
  • r (float) – Radius of the circle. The coordinate system is specified in cs.
  • cs

    Coordinate system for the values in x and r. Valid coordinate system choices include:

    • ’axes mm’ : mm from lower left corner of axes
    • ’data’ : use the axes data coordinate system
  • kwargs – Keyword arguments to matplotlib’s Circle class
Returns:

patch_obj

Return type:

matplotlib patch object

add_h_line(y, **kwargs)

Adds a horizontal line that spans the axes

Parameters:
  • y (float) – y-coordinate of line
  • color (1x3 list, optional) – Color of line. RGB values should be between 0 and 1.
  • width (float, optional) – Width of line, in points.
  • style (string, optional) – Style of line. Valid styles include ‘-’, ‘–’, ‘-.’, ‘:’.
  • kwargs – Keyword arguments to matplotlib’s line2D. See the matplotlib documentation for further details
Returns:

line

Return type:

line2D instance

add_h_rect(y, **kwargs)

Adds a horizontal rectangle that spans the axes

Parameters:
  • y (1x2 numpy array) – y-coordinates of rectangle’s bottom and top edes
  • color (1x3 list, optional) – Color of rectangle. RGB values should be between 0 and 1.
  • edge_color (1x3 list, optional) – Color of rectangle edges. RGB values should be between 0 and 1.
  • edge_width (float, optional) – Width of rectangle edges, in points.
  • edge_style (string, optional) – Style of edges. Valid styles include ‘-’, ‘–’, ‘-.’, ‘:’.
  • kwargs – Keyword arguments to matplotlib’s polygon. See the matplotlib documentation for further details
Returns:

span

Return type:

polygon instance

add_image(im, **kwargs)

Adds an image to the axes

Parameters:clearplot.axes._Data_Axes_Base.add_image() (See) –
add_legend(artists=None, loc='best', outside_ax=False, **kwargs)

Adds a legend using labels previously associated with artists

Parameters:
  • artists (list of data objects, optional) – Curves, markers, bars, etc. that will be labeled. Input None to label the artist type specified in artist type.
  • loc (string, optional) – Location of legend. Valid options include, ‘best’, ‘upper left’, ‘upper center, ‘upper right’, ‘center left’, ‘center’, ‘center right’, ‘lower left’, ‘lower center’, ‘lower right’.
  • outside_ax (bool, optional) – Specifies whether to place the legend outside the axes.
Returns:

legend

Return type:

legend object

add_line(x, **kwargs)

Adds a 2D line to the axes

Parameters:
  • x (Nx2 numpy array) – Coordinates of the line in mm, relative to the axes lower left corner. Each row contains a point on the line. Coordinates can be outside the plotting area.
  • kwargs – Keyword arguments to matplotlib’s Line2D class
Returns:

line_obj

Return type:

matplotlib line object

See also

annotate()
adds an annotation to the axes
add_text(x, txt, font_size=16.0, **kwargs)

Adds text to the axes

Parameters:
  • x (1x2 numpy array) – Coordinates of the text in mm, relative to the axes lower left corner.
  • txt (string) – Text to add to the figure
  • font_size (float) – Text font size
  • kwargs – Keyword arguments to matplotlib’s text function
Returns:

txt_obj

Return type:

text object

See also

annotate()
adds an annotation to the axes
add_title(text, **kwargs)

Adds a title above axes.

Parameters:
  • text (string) – LaTeX formatted string for the title
  • kwargs – Keyword arguments to matplotlib’s set_title function. See the matplotlib documentation for further details
add_v_line(x, **kwargs)

Adds a vertical line that spans the axes

Parameters:
  • x (float) – x-coordinate of line
  • color (1x3 list, optional) – Color of line. RGB values should be between 0 and 1.
  • width (float, optional) – Width of line, in points.
  • style (string, optional) – Style of line. Valid styles include ‘-’, ‘–’, ‘-.’, ‘:’.
  • kwargs – Keyword arguments to matplotlib’s line2D. See the matplotlib documentation for further details
Returns:

line

Return type:

line2D instance

add_v_rect(x, **kwargs)

Adds a vertical rectangle that spans the axes

Parameters:
  • x (1x2 numpy array) – x-coordinates of rectangle’s left and right edges
  • color (1x3 list, optional) – Color of rectangle. RGB values should be between 0 and 1.
  • edge_color (1x3 list, optional) – Color of rectangle edges. RGB values should be between 0 and 1.
  • edge_width (float, optional) – Width of rectangle edges, in points.
  • edge_style (string, optional) – Style of edges. Valid styles include ‘-’, ‘–’, ‘-.’, ‘:’.
  • kwargs – Keyword arguments to matplotlib’s polygon. See the matplotlib documentation for further details
Returns:

span

Return type:

polygon instance

annotate(text, x_1, cs_1, x_2=None, cs_2=['axes mm', 'axes mm'], **kwargs)

Adds an annotation to the axes. Annotations can be just text or complex arrows with circled text, depending on the keyword arguments. This method is essentially a wrapper around matplotlib’s ax.annotate method.

Parameters:
  • text (string) – Text to add to the axes. Input an empty string (‘’) to omit text.
  • x_1 (1x2 numpy array or list) – Coordinates at start of the annotation. The coordinate system(s) is specified in cs_1. If text is supplied, it is placed at this location.
  • cs_1 (string or list) –

    Coordinate system(s) for the values in x_1. Input a single string to make both coordinates in x_1 use the same coordinate system. Input a 1x2 list to specify different coordinate systems for each coordinate in x_1. Valid coordinate system choices include:

    • ’figure mm’ : mm from the lower left corner of the figure
    • ’figure fraction’ : 0,0 is lower left of figure and 1,1 is upper, right
    • ’axes mm’ : mm from lower left corner of axes
    • ’axes fraction’ : 0,0 is lower left of axes and 1,1 is upper right
    • ’offset mm’ : Specify an offset (in mm) from the x_2 value
    • ’data’ : use the axes data coordinate system
  • x_2 (1x2 numpy array, optional) – Coordinates at end of the annotation. The coordinate system is specified in cs_2.
  • cs_2 (string or list, optional) – Coordinate system for the values in x_2. See description for cs_1 for further information.
  • kwargs – Keyword arguments to matplotlib’s annotate function. See the matplotlib documentation for further details
Returns:

ann_obj

Return type:

annotation object

See also

Axes.label_curve()
Place multiple labels on a single curve
Axes.label_curves()
Place a label on each curve
bbox

Gets a bounding box for the axes plotting area in mm, relative to the lower left corner of the figure.

get_obj_bbox(obj)

Finds the coordinates of the bounding box surrounding an object, in mm, relative to the lower left corner of the axes

Parameters:obj (graphics primitive object) – object you wish to get the bounding box for
Returns:bbox
Return type:bounding box object
label_curve(curve, labels, **kwargs)

Prints one or more labels on a single curve, either at interactively picked points or at user specified locations.

Parameters:
  • curve (curve object) – Curve to label
  • labels (list of strings) – Label strings (in LaTeX format)
  • style ('normal' or 'balloon', optional) – Input ‘normal’ to create labels without circles around them. The default is ‘balloon’ labels, with circles around them.
  • Axes.label_curves for descriptions of other input parameters (See) –
Returns:

  • If labels have been interactively picked, prints ndx, angles, and
  • lengths so the user can input them directly next time.

See also

Axes.label_curves()
Place a label on each curve
label_curves(**kwargs)

Labels curves using labels previously associated with curves. Labels are placed either at interactively picked points or at user specified locations.

Parameters:
  • curves (list of curves, optional) – curves to be labeled
  • ndx (integer or list of integers, optional) – list of indices that specify the location of the leader line root
  • angles (float or list of floats, optional) – list of leader line angles or a single angle (in degrees)
  • lengths (float or list of floats, optional) – list of leader line lengths or a single length (in points)
  • pick ('root', 'text', or False, optional) – Input ‘root’ or ‘text’ to interactively chose the label positions. If ‘root’ is specified, the user selects the leader line root position with the cursor, and specified or default values are used for the leader line length and angle. If ‘text’ is specified, the user selects the position of the text and the leader line is extended until it intersects the curve at the specified or default angle.
  • style ('normal' or 'balloon', optional) – Input ‘balloon’ to create labels with circles around them. The default is ‘normal’ labels, without circles around them.
  • font_size (float, optional) – font size (in points) for label text
Returns:

  • If labels have been interactively picked, prints ndx, angles, and
  • lengths so the user can input them directly next time.

See also

Axes.label_curve()
Place multiple labels on a single curve
plot(x, y, labels=[None], **kwargs)

Plots x and y data as 2D curves on the axes

Parameters:
  • x (1xN list of numpy arrays) – x-coordinates of curves
  • y (1xN list of numpy arrays) – y-coordinates of curves
  • labels (list, optional) – Curve labels (in LaTeX format). (Use add_legend or a similar command to make the labels visible.)
  • curve_colors (list of 1x3 lists, optional) – Colors of curves. RGB values should be between 0 and 1.
  • curve_styles (list of strings, optional) – Styles of curves. Valid styles include ‘-’, ‘–’, ‘-.’, ‘:’.
  • curve_widths (list of floats or ints, optional) – Width of curves in points.
  • marker_shapes (list of strings, optional) – Shapes of markers. See the matplotlib documentation for valid shapes.
  • marker_sizes (list of floats or ints, optional) – Sizes of markers, in points.
  • marker_colors (list of 1x3 lists, optional) – Colors of marker faces. RGB values should be between 0 and 1.
  • marker_edge_widths (list of floats or ints, optional) – Width of marker edges in points.
  • marker_edge_colors (list of 1x3 lists, optional) – Colors of marker edges. RGB values should be between 0 and 1.
Returns:

curves

Return type:

list of curve instances

See also

Axes.plot_markers()
similar to Axes.plot, except it plots markers that can be added to the marker legend
plot_bars(x, y, labels=[None], **kwargs)

Plots x–y data as vertical bars on the axes

Parameters:
  • x (1xN list of numpy arrays) – x coordinates of bars
  • y (1xN list of numpy arrays) – Height of bars
  • labels (list, optional) – Bar labels (in LaTeX format). (Use add_legend or a similar command to make the labels visible.)
  • widths (list of floats or ints, optional) – Width of bars in x-coordinate units
  • colors (list of 1x3 lists, optional) – Colors of bars. RGB values should be between 0 and 1.
  • edge_styles (list of strings, optional) – Styles of bar edges. Valid options include ‘-’, ‘–’, ‘-.’, ‘:’, or ‘None’
  • edge_widths (list of floats, optional) – Width of bar edges (in points).
  • edge_colors (list of 1x3 lists, optional) – Colors of bar edges. RGB values should be between 0 and 1.
  • align (['center' | 'edge'], optional) – Specifies which part of the bar to align to the x coordinate
Returns:

bars

Return type:

list of bar instances

plot_box_and_whiskers(x, y, **kwargs)

Plot distributions of data in a box and whiskers plot on the axes

Parameters:
  • x (1xN list of numpy arrays) – x coordinates of boxes
  • y (1xN list of numpy arrays) – Distributions of data
  • box_widths (list of floats, optional) – Horizontal width of boxes in x data units
  • box_colors (list of 1x3 lists, optional) – Colors of boxes. RGB values should be between 0 and 1.
  • box_edge_styles (list of strings, optional) – Styles of box edges. Valid options include ‘-’, ‘–’, ‘-.’, ‘:’, or ‘None’
  • box_edge_widths (list of floats, optional) – Widths of box edges, in points.
  • box_edge_colors (list of 1x3 lists of , optional) – Colors of box edges. RGB values should be between 0 and 1.
  • whisker_styles (list of strings, optional) – Styles of whiskers. Valid options include ‘-’, ‘–’, ‘-.’, ‘:’, or ‘None’
  • whisker_widths (list of floats, optional) – Widths of whiskers, in points.
  • whisker_colors (list of 1x3 lists, optional) – Colors of whiskers. RGB values should be between 0 and 1.
  • cap_styles (list of strings, optional) – Styles of caps. Valid options include ‘-’, ‘–’, ‘-.’, ‘:’, or ‘None’
  • cap_widths (list of floats, optional) – Widths of caps, in points.
  • cap_colors (list of 1x3 lists, optional) – Colors of caps. RGB values should be between 0 and 1.
  • flier_shapes (list of strings, optional) – Shapes of fliers. See the matplotlib documentation for valid shapes.
  • flier_sizes (list of floats, optional) – Size of fliers in points.
  • flier_colors (list of 1x3 lists, optional) – Colors of flier faces. RGB values should be between 0 and 1.
  • flier_edge_widths (list of floats, optional) – Widths of flier edges, in points.
  • flier_edge_colors (list of 1x3 lists, optional) – Colors of flier edges. RGB values should be between 0 and 1.
plot_contours(x, y, z, **kwargs)

Plot three dimensional data as contours on the axes

Parameters:
  • x (MxN numpy array) – x-coordinates of points
  • y (MxN numpy array) – y-coordinates of points
  • z (MxN numpy array) – z-coordinates of points. z-coordinates are used to create contours.
  • plot_type (['filled' | 'intensity map' | 'lines'], optional, default: 'filled') –

    Type of contour plot. Valid options are:

    • filled: the area between two neighboring contour lines is filled in with a single color.
    • intensity map: contour lines are overlaid on the z data, which is plotted as an intensity map. The x and y data must be on a uniform grid. In other words, all the columns of x must have the same spacing dx, and all the rows of y must have the same spacing dy. (If your data is on an irregular grid, you can always interpolate it onto a uniform grid.) Because a uniform grid is assumed, only the min and max values of x and y are used to place the intensity map.
    • lines: plots only contour lines.
  • c_map (string, optional) – Color map for background and contour lines
  • c_lim (1x2 list, optional) – Color map limits.
  • c_scale (['linear' | 'log'], optional) – Color map scaling
  • cl_levels (list of floats, optional) – Contour line levels.
  • cl_labels (list of floats, optional) – Contour lines to label.
  • cl_label_fsize (float or int, optional) – Contour line labels font size (in points).
  • cl_label_fmt (string, optional) – Label format string. Ex: ‘%.2f’, ‘%g’, or ‘%d’
  • cl_width (float or int, optional) – Contour line width (in points).
  • cl_style (['_' | '-' | '--' | ':' | None], optional, default: '-') – Contour line style.
  • cl_colors (list, optional) – Contour line colors (in RGB format).
Returns:

  • b_obj (contourf object, image object, or None) – background object
  • cl_obj (contour line object)

See also

Axes.add_image()

plot_functions.show_imgs()
bar
plot_error_bars(x, y, **kwargs)

Plots error bars at each x–y data point

Parameters:
  • x (1xN list of numpy arrays) – x-coordinates of error bar centers
  • y (1xN list of numpy arrays) – y-coordinates of error bar centers
  • x_err (1xN list of numpy arrays or None objects, optional) – x error deltas. Supply 1xM numpy array(s) to draw symmetric error bars or 2xM numpy array(s) to draw assymetric error bars. Supply None object(s) to skip drawing x error bars for a given data set.
  • y_err (1xN list of numpy arrays or None objects, optional) – y error deltas. Supply 1xM numpy array(s) to draw symmetric error bars or 2xM numpy array(s) to draw assymetric error bars. Supply None object(s) to skip drawing x error bars for a given data set.
  • colors (list of 1x3 lists, optional) – Colors of error bars. RGB values should be between 0 and 1.
  • bar_line_widths (list of floats or ints, optional) – Width of error bar lines in points.
  • cap_line_widths (list of floats or ints, optional) – Width of error bar cap line widths in points.
  • cap_lengths (list of floats or ints, optional) – Length of error bar cap in points.

See also

Axes.plot()
similar to Axes.plot_markers, except it plots curves that can be added to the curve legend
Axes.plot_error_bars()
plots error bars
plot_intensity_map(x, y, z, **kwargs)

Plots a intensity map (heat map) as an image on the axes.

Parameters:
  • x (1x2 or MxN numpy array) – Matrix x position.
  • y (1x2 or MxN numpy array) – Matrix y position.
  • z (MxN numpy array) – Matrix to be plotted
  • c_map (string, optional) – Image color map.
  • c_lim (1x2 list, optional) – Color map limits. To automatically chose a limit, input None for either the upper or lower limit.
  • c_scale (['linear' | 'log'], optional) – Color scaling.
Returns:

im_obj

Return type:

matplotlib image object

See also

ax.add_image(), ax.add_color_bar(), ax.plot_contours()

Notes

clip_edges causes the edges of the matrix to conform to the min/max of x/y by applying a clipping mask to the image object. The actual edges of the image object still extend beyond the min/max of x/y by half a pixel on either side. If the size of the half pixel relative to the tick mark spacing is larger than the ax.exceed_lim percentage, then the automatically selected axes limits will extend an extra tick mark beyond the edge of the visible (clipped) data. To avoid this, either specify the x/y limits explicitly, increase ax.exceed_lim, or reduce the size of the pixel relative to the tick mark spacing.

plot_markers(x, y, labels=[None], **kwargs)

Plots x and y data as markers on the axes

Parameters:
  • x (1xN list of numpy arrays) – x-coordinates of markers
  • y (1xN list of numpy arrays) – y-coordinates of markers
  • labels (list of strings, optional) – Marker labels (in LaTeX format). (Use add legend or a similar command to make labels visible.)
  • shapes (list of strings, optional) – Shapes of markers. See the matplotlib documentation for valid shapes.
  • sizes (list of floats or ints, optional) – Sizes of markers, in points.
  • colors (list of 1x3 lists, optional) – Colors of marker faces. RGB values should be between 0 and 1.
  • edge_widths (list of floats or ints, optional) – Width of marker edges in points.
  • edge_colors (list of 1x3 lists, optional) – Colors of marker edges. RGB values should be between 0 and 1.
Returns:

markers

Return type:

list of marker instances

See also

Axes.plot()
Similar to Axes.plot_markers, except it plots curves that can be added to the curve legend
Axes.plot_error_bars()
Plots error bars at each data point
plot_violins(x, y, **kwargs)

Plot distributions of data in a violin plot on the axes

Parameters:
  • x (1xN list of numpy arrays) – x coordinates of violins
  • y (1xN list of numpy arrays) – Distributions of data
  • body_widths (list of floats, optional) – Horizontal width of violin bodies in x data units
  • body_colors (list of 1x3 lists, optional) – Colors of violin bodies. RGB values should be between 0 and 1.
  • body_edge_styles (list of strings, optional) – Styles of violin body edges. Valid options include ‘-‘, ‘–’, ‘-.’, ‘:’, or ‘None’
  • body_edge_widths (list of floats, optional) – Widths of violin body edges, in points.
  • body_edge_colors (list of 1x3 lists of , optional) – Colors of violin body edges. RGB values should be between 0 and 1.
  • show_means (bool, optional) – Show mean of each distribution of data
  • show_medians (bool, optional) – Show median of each distribution of data
  • show_extrema (bool, optional) – Show extrema of each distribution of data
  • line_styles (list of strings, optional) – Styles of mean/median/extrema edges. Valid options include ‘-‘, ‘–’, ‘-.’, ‘:’, or ‘None’
  • line_widths (list of floats, optional) – Widths of mean/median/extrema edges, in points.
  • line_colors (list of 1x3 lists, optional) – Colors of mean/median/extrema edges. RGB values should be between 0 and 1.
position

Gets/sets the position of the axes lower left corner in mm, relative to the lower left corner of the figure window.

size

Get/set the size of the axes. Supply a 1x2 numpy array in mm units to specify a new size.

tight_bbox

Gets a bounding box in mm that includes the tick marks and tick mark labels, relative to the lower left corner of the figure area. Bounding box does not include axes labels, axes title, or other annotations.

x_label

Gets/sets the x axis label. Supply a 1x2 list of strings (in LaTeX syntax) to specify the axis label text and axis units. The units will automatically be wrapped in paranthesises. Supply a 1x1 list with a single string to create a label without any units.

x_lim

Gets/sets the x axis limits. Supply a 1x2 list of floats to explicitly set the upper and lower limits. If the string None is input instead of a float, then the corresponding limit will be automaticaly selected.

x_scale

Gets/sets the scaling for the x-axis. Valid inputs include ‘linear’, ‘log’, and ‘symlog’. Note: if you change the scaling when the axis limits and ticks are set to None (the default), then the limits and ticks will be recomputed.

x_scale_log_base

Gets/sets the logarithmic base for log scaling on the x-axis.

x_tick

Gets/sets the x axis tick mark spacing. Supply a float to explicitly set the tick marks spacing. If x_tick is set to None, then the tick mark spacing will be automatically selected.

x_tick_labels

Gets/sets x axis tick labels. Assign a list of strings to set the labels.

x_tick_list

Gets/sets x-axis tick mark positions. Supply a list of values to explicitly set the tick mark values. If x_tick_list is set to None, then the tick marks will be automaticaly selected.

x_tick_mm

Gets/sets the physical distance (in mm) between the tick marks on the x axis. Input a float to specify a new spacing.

y_label

Gets/sets the y axis label. Supply a 1x2 list of strings (in LaTeX syntax) to specify the axis label text and axis units. The units will automatically be wrapped in paranthesises. Supply a 1x1 list with a single string to create a label without any units.

y_lim

Gets/sets the y axis limits. Supply a 1x2 list of floats to explicitly set the upper and lower limits. If the string None is input instead of a float, then the corresponding limit will be automaticaly selected.

y_scale

Gets/sets the scaling for the y-axis. Valid inputs include ‘linear’, ‘log’, and ‘symlog’. Note: if you change the scaling when the axis limits and ticks are set to None (the default), then the limits and ticks will be recomputed.

y_scale_log_base

Gets/sets the logarithmic base for log scaling on the y-axis.

y_tick

Gets/sets the y axis tick mark spacing. Supply a float to explicitly set the tick marks spacing. If y_tick is set to None, then the tick mark spacing will be automatically selected.

y_tick_labels

Gets/sets y axis tick labels. Assign a list of strings to set the labels.

y_tick_list

Gets/sets y-axis tick mark positions. Supply a list of values to explicitly set the tick mark values. If y_tick_list is set to None, then the tick marks will be automaticaly selected.

y_tick_mm

Gets/sets the physical distance (in mm) between the tick marks on the y axis. Input a float to specify a new spacing.

class Invisible_Axes(fig, **kwargs)

Bases: clearplot.axes._Data_Axes_Base

A lightweight set of invisible axes for images, annotations, diagrams, etc.

__init__(fig, **kwargs)

Creates a lightweight set of invisible axes.

Parameters:
  • fig (figure object) – Figure to place the invisible axes in.
  • position (1x2 list or numpy array, optional) – Position of the lower left corner of the axes with respect to the lower left corner of the figure (in mm)
  • size (1x2 list or numpy array, optional) – Width and height of axes (in mm)
  • scale_plot (float, optional) – Scales distances between different objects associated with the axes
Returns:

Return type:

axes object

add_arrow(style_str, x, cs, orient, length, head_length=7.0, head_aspect_ratio=3.0, color=[0, 0, 0])

Creates an arrow with a curved back. The arrow can be placed relative to several coordinate systems, yet it retains it’s shape, even when the data limits, axes, or figure window change size.

Parameters:
  • x (1x2 numpy array) – Tip of arrowhead, in the coordinate system(s) specified in x_coord_sys
  • cs (string or 1x2 list) – Specifies the coordinate system for the coordinates in x. See description of cs_1 in the axes.annotate method for further information.
  • orient (float) – Orientation angle (rad) of arrow
  • length (float, optional) – Length of the arrow, in mm
  • = float, optional (head_length) – Length of the arrowhead
  • head_aspect_ratio (float, optional) – Length/width ratio of the arrowhead
  • color (1x3 list, optional) – RGB value for the arrow
Returns:

arrow

Return type:

annotation object

add_arrowhead(x, cs, orient, length=7.0, aspect_ratio=2.5, color=[0, 0, 0])

Creates an arrowhead with a curved back. The arrow can be placed relative to several coordinate systems, yet it retains it’s shape, even when the data limits, axes, or figure window change size.

Parameters:
  • x (1x2 numpy array) – Tip of arrowhead, in the coordinate system(s) specified in x_coord_sys
  • cs (string or 1x2 list) – Specifies the coordinate system for the coordinates in x. See description of cs_1 in the axes.annotate method for further information.
  • orient (float) – Orientation angle (rad) of arrowhead
  • length (float, optional) – Length of the arrowhead, in mm
  • aspect_ratio (float, optional) – Length/width ratio of the arrowhead
  • color (1x3 list, optional) – RGB value for the arrowhead
Returns:

arrowhead

Return type:

annotation object

add_circle(x, r, cs='axes mm', **kwargs)

Adds a circle to the axes

Parameters:
  • x (1x2 numpy array) – Coordinates of the circle center. The coordinate system is specified in cs.
  • r (float) – Radius of the circle. The coordinate system is specified in cs.
  • cs

    Coordinate system for the values in x and r. Valid coordinate system choices include:

    • ’axes mm’ : mm from lower left corner of axes
    • ’data’ : use the axes data coordinate system
  • kwargs – Keyword arguments to matplotlib’s Circle class
Returns:

patch_obj

Return type:

matplotlib patch object

add_image(im, **kwargs)

Adds an image to the current axes

Parameters:
  • im (MxN or MxNx3 numpy array) – Image to be added to axes
  • x (1x2 numpy array, optional) – Image x position.
  • y (1x2 numpy array, optional) – Image y position.
  • xy_coords (string, optional) – Defines the meaning of x and y coordinates. If ‘edges’ is input, then the image edges will correspond to the coordinates in x and y. If ‘pixel centers’ is input then the center of the pixels at the image edges will correspond to the coordinates in x and y.
  • im_origin (string, optional) – Origin for the image indices. If ‘upper left’ is input, then the [0,0] index is the upper left of the image, with positive y being downwards. If ‘lower left’ is input, then the [0,0] index is the lower left of the image, with positive y being upwards.
  • im_interp (string, optional) – Image interpolation method. See the matplotlib documentation for acceptable values.
  • c_map (string, optional) – Image color map.
  • c_lim (1x2 list, optional) – Color map limits. To automatically chose a limit, input None for either the upper or lower limit.
  • c_scale (['linear' | 'log'], optional) – Color scaling.
Returns:

im_obj

Return type:

matplotlib image object

See also

Figure.add_color_bar()

add_line(x, **kwargs)

Adds a 2D line to the axes

Parameters:
  • x (Nx2 numpy array) – Coordinates of the line in mm, relative to the axes lower left corner. Each row contains a point on the line. Coordinates can be outside the plotting area.
  • kwargs – Keyword arguments to matplotlib’s Line2D class
Returns:

line_obj

Return type:

matplotlib line object

See also

annotate()
adds an annotation to the axes
add_scale_bar(length, text, loc='lower left', font_size=16.0)

Adds a scale bar just outside of the invisible axes.

Parameters:
  • length (float) – Length of the scale bar in axis data units
  • text (str) – Label that delinates the physical length signified by the scale bar
  • loc (['lower left' | 'upper left'], optional) – Scale bar location. ONLY ‘LOWER LEFT’ is implemented at this time.
  • font_size (float) – Font size of the text
Returns:

scale_bar

Return type:

annotation object

add_text(x, txt, font_size=16.0, **kwargs)

Adds text to the axes

Parameters:
  • x (1x2 numpy array) – Coordinates of the text in mm, relative to the axes lower left corner.
  • txt (string) – Text to add to the figure
  • font_size (float) – Text font size
  • kwargs – Keyword arguments to matplotlib’s text function
Returns:

txt_obj

Return type:

text object

See also

annotate()
adds an annotation to the axes
add_title(text, **kwargs)

Adds a title above axes.

Parameters:
  • text (string) – LaTeX formatted string for the title
  • kwargs – Keyword arguments to matplotlib’s set_title function. See the matplotlib documentation for further details
annotate(text, x_1, cs_1, x_2=None, cs_2=['axes mm', 'axes mm'], **kwargs)

Adds an annotation to the axes. Annotations can be just text or complex arrows with circled text, depending on the keyword arguments. This method is essentially a wrapper around matplotlib’s ax.annotate method.

Parameters:
  • text (string) – Text to add to the axes. Input an empty string (‘’) to omit text.
  • x_1 (1x2 numpy array or list) – Coordinates at start of the annotation. The coordinate system(s) is specified in cs_1. If text is supplied, it is placed at this location.
  • cs_1 (string or list) –

    Coordinate system(s) for the values in x_1. Input a single string to make both coordinates in x_1 use the same coordinate system. Input a 1x2 list to specify different coordinate systems for each coordinate in x_1. Valid coordinate system choices include:

    • ’figure mm’ : mm from the lower left corner of the figure
    • ’figure fraction’ : 0,0 is lower left of figure and 1,1 is upper, right
    • ’axes mm’ : mm from lower left corner of axes
    • ’axes fraction’ : 0,0 is lower left of axes and 1,1 is upper right
    • ’offset mm’ : Specify an offset (in mm) from the x_2 value
    • ’data’ : use the axes data coordinate system
  • x_2 (1x2 numpy array, optional) – Coordinates at end of the annotation. The coordinate system is specified in cs_2.
  • cs_2 (string or list, optional) – Coordinate system for the values in x_2. See description for cs_1 for further information.
  • kwargs – Keyword arguments to matplotlib’s annotate function. See the matplotlib documentation for further details
Returns:

ann_obj

Return type:

annotation object

See also

Axes.label_curve()
Place multiple labels on a single curve
Axes.label_curves()
Place a label on each curve
bbox

Gets a bounding box for the axes plotting area in mm, relative to the lower left corner of the figure.

get_obj_bbox(obj)

Finds the coordinates of the bounding box surrounding an object, in mm, relative to the lower left corner of the axes

Parameters:obj (graphics primitive object) – object you wish to get the bounding box for
Returns:bbox
Return type:bounding box object
position

Gets/sets the position of the axes lower left corner in mm, relative to the lower left corner of the figure window.

size

Get/set the size of the axes. Supply a 1x2 numpy array in mm units to specify a new size.

tight_bbox

Gets a bounding box in mm that includes the tick marks and tick mark labels, relative to the lower left corner of the figure area. Bounding box does not include axes labels, axes title, or other annotations.

x_lim

Gets/sets the x axis limits. Supply a 1x2 list of floats to explicitly set the upper and lower limits.

y_lim

Gets/sets the y axis limits. Supply a 1x2 list of floats to explicitly set the upper and lower limits.