clearplot.utilities module¶
-
class
Offset_From
(artist, ref_pt, units='mm')¶ Bases:
object
Generates a transformation object to offset from another object
-
__init__
(artist, ref_pt, units='mm')¶ Parameters: - artist (Artist, Bounding Box, or Transform) – object to offset from
- ref_pt (1x2 list) – Point on the object to offset from. Must be specified in normalized bounding box coordinates of the object.
- units ('points', 'pixels', or 'mm') – Units for the offset
-
get_units
()¶
-
set_units
(units)¶
-
-
adjust_depth
(a, proper_depth)¶ Finds the depth of a list or numpy array and adjusts it as necessary
Parameters: - a (list or numpy array) – List or array to be modified
- proper_depth (integer) – Depth that a will be returned with
Returns: a – The input a, modified to have the proper depth
Return type: list or numpy array
-
adjust_list_depth
(a, proper_depth)¶ Finds the depth of a list and adjusts it as necessary
Parameters: - a (list or any other object) – List to be modified
- proper_depth (integer) – Depth that a will be returned with
Returns: a – The input a, modified to have the proper depth
Return type: list
-
convert_err_to_nested_numpy_arrays
(g)¶ Finds the bottom of nested lists and converts to N x 2 numpy arrays, as needed.
Parameters: a (list) – Nested list of arbitrary depth that may or may not have numpy arrays at the bottom Returns: - a (list) – Nested list of numpy arrays.
- not_numpy (boolean) – Used during the recurssion process. Not intended for the end user.
-
cycle_thru_list
(list_obj, i)¶ Cycles through a list
Parameters: - list_obj (list) – List to be cycled through
- i (int) – Index of list to be put in the first position
Returns: cycled_list – List with index i now in the first position
Return type: list
-
find_and_select_lim_and_tick
(ui_lim, ui_tick, data_lim, ax_scale, ax_log_base, exceed_lim)¶ Convenience function that combines find_candidate_lim_and_tick with select_lim_and_tick.
-
find_candidate_lim_and_tick
(ui_lim, ui_tick, data_lim, ax_scale, ax_log_base, exceed_lim)¶ Finds candidate limits and tick mark spacings
Parameters: - ui_lim (1x2 list or numpy array) – User input axis limits. Either element can be set to None to have algorithm automatically select the low or high limit.
- ui_tick (float) – User input tick mark spacing. Set to None to automatically select the tick mark spacing.
- data_lim (1x2 list or numpy array) – Limits of the data on the axis.
- ax_scale (['linear' | 'log']) – Axis scaling.
- ax_log_base (float) – Base of the logarithm for log scaled axes. (Not used for linearly scaled axes.)
- exceed_lim (float) – When automatically selecting limits, the data is allowed to exceed the limits by this ratio of the tick mark spacing.
Returns: - lim_c (Nx2 list or numpy array) – A list of axis limit candidates
- tick_c (Nx1 list or numpy array) – A list of tick mark spacing candidates.
- n_tick_c (Nx1 list or numpy array) – A list of number of tick marks candidates
-
find_depth
(a)¶ Finds the depth of a list or numpy array using recursion
Parameters: a (list or numpy array) – list or array of arbitrary depth Returns: depth – depth of list Return type: integer
-
find_list_depth
(a)¶ Finds the depth of a list using recursion
Parameters: a (list) – list of arbitrary depth Returns: depth – depth of list Return type: integer
-
flatten
(a)¶ Flattens list of lists with arbitrary depth into a 1-D list.
Parameters: l (list) – list to be flattened Returns: flat_l – flattened list Return type: list
-
gen_tick_list
(ui_tick_list, lim, tick, scale, log_base)¶ Generates a list of tick mark values
Parameters: - ui_tick_list (list or None) – User input list of tick mark values, or None to automatically generate a tick mark list
- lim (1x2 list or numpy array) – Axis limits.
- tick (float) – Tick mark spacing
- scale (['log' | 'linear']) – Axis scaling
- log_base (float) – Logarithm base for log scaled axes
Returns: tick_list – List of tick mark values
Return type: list of floats
-
get_im_window_extent
(im_obj, ax)¶ Gets the bounding box for an image in display (pixel) coordinates
-
get_unique_rows
(array)¶ Finds the unique rows of an array
-
preprocess_input
(ui, depth, C)¶
-
raw_string
(txt)¶ Python automatically converts escape characters (i.e. n), which causes problems when inputing latex strings since they are full of backslashes. This function returns a raw string representation of text
Parameters: txt (string) – string that possibly contains escape characters Returns: new_text – same as ‘text’ but without any escape characters Return type: string
-
select_lim_and_tick
(lim_c, tick_c, n_tick_c)¶ Select limits and tick mark spacings that give a pleasing number of tick marks
Parameters: - lim_c (Nx2 list or numpy array) – A list of axis limit candidates
- tick_c (Nx1 list or numpy array) – A list of tick mark spacing candidates.
- n_tick_c (Nx1 list or numpy array) – A list of number of tick marks candidates
Returns: - lim (1x2 list or numpy array) – Optimum axis limits
- tick (float) – Optimum tick mark spacing
- n_tick_c (float or int) – Optimum number of tick marks
-
set_im_interp
(im_interp, im_obj, ax)¶ Sets the proper image interpolation type for an image.
Parameters: - im_interp (str) – Image interpolation type. If None, then algorithm choses either ‘nearest’ or ‘none’. If the image is blown up, then it uses ‘nearest’. If the image is scaled down then it uses ‘none’. See this matplotlib example and this matplotlib example for further details.
- im_obj (image object) – Image to set the interpolation type on.
- ax (axes object) – Axes containing im_obj