clearplot.color_bar module¶
-
class
Color_Bar
(data_obj, **kwargs)¶ Bases:
clearplot.axes._Axes_Base
A color bar class
-
__init__
(data_obj, **kwargs)¶ Instantiates a color bar object
Parameters: - data_obj (data object or a list of data objects) – Image or contours that the color bar pertains to
- position (1x2 list or numpy array, optional) – Position of color bar lower left corner from the figure lower left corner, in mm.
- ax_2_bar_gap (float, optional) – Gap between axes and color bar, in mm. Only utilized if postion is automatically determined.
- orient (['v', 'h'], optional) – Orientation of the color bar
- tick (float, optional) – Tick mark spacing. If tick is set to None, then the tick mark spacing will be automatically selected.
- tick_list (list, optional) – Tick mark positions. If tick_list is set to None, then the tick marks will be automaticaly selected.
- tick_labels (list of strings, optional) – Tick mark labels. If tick_labels is set to None, then the tick marks will be automaticaly selected.
- lim (1x2 list, optional) – Lower and upper limits. If None is input instead of a float, then the corresponding limit will be automatically selected.
- scale ([ 'linear' | 'log' ], optional) – Color bar scaling. The default is ‘linear’.
-
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_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
-
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
¶ Sets/gets the color bar 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.
-
lim
¶ Gets/sets the color bar limits. Supply a 1x2 list of floats to explicitly set the upper and lower limits. If None is input instead of a float, then the corresponding limit will be automaticaly selected.
-
position
¶ Gets/sets the position of the axes lower left corner in mm, relative to the lower left corner of the figure window.
-
scale
¶ Gets/sets the scaling for the color bar. Valid inputs include ‘linear’ and ‘log’. 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.
-
size
¶ Get/set the size of the axes. Supply a 1x2 numpy array in mm units to specify a new size.
-
tick
¶ Get/sets the color bar tick mark spacing. Supply a float to explicitly set the tick marks spacing. If tick is set to None, then the tick mark spacing will be automatically selected.
-
tick_labels
¶ Gets/sets tick labels. Assign a list of strings to set the labels.
-
tick_list
¶ Gets/sets tick mark positions. Supply a list of values to explicitly set the tick mark positions. If tick_list is set to None, then the tick marks will be automaticaly selected.
-
tick_mm
¶ Gets/sets the physical distance (in mm) between the tick marks. Input a float to specify a new spacing.
-
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.
-