casys.visualization.figure

Low level drawing classes.

Functions

compute_inverse_axis_ticks(values)

This function performs the computation of the inverse axis ticks positions for a logarithmic scale, relatively to the original axis values.

is_text_property(prop)

Check whether the given property is a valid Text property or not.

Classes

FigureHandler(figure[, projection])

class casys.visualization.figure.FigureHandler(figure, projection=None)

Bases: object

Parameters:
COLORS = ['blue', 'red', 'green', 'magenta', 'darkorange', 'cyan', 'darkblue', 'darkred', 'darkcyan', 'darkgreen', 'gold', 'black', 'yellow']
COLORS_CODE = {'#000000': 'black', '#00008B': 'darkblue', '#0000FF': 'blue', '#006400': 'darkgreen', '#008000': 'green', '#008B8B': 'darkcyan', '#00FFFF': 'cyan', '#8B0000': 'darkred', '#FF0000': 'red', '#FF00FF': 'magenta', '#FF8C00': 'darkorange', '#FFD700': 'gold', '#FFFF00': 'yellow'}
COLORS_SL = {'b': 'blue', 'c': 'cyan', 'g': 'green', 'k': 'black', 'm': 'magenta', 'r': 'red', 'w': 'white', 'y': 'yellow'}
add_2d_scatter(*, x, y, z, params, discretized, ax=None)

Add a 2D scatter plot.

Parameters:
  • x (ndarray) – x-axis data.

  • y (ndarray) – y-axis data.

  • z (ndarray) – z-axis data.

  • params (PlotParams) – Plot parameters.

  • discretized (bool) – Whether the color map is discretized or not.

  • ax (Axes | None) – Axes on which to draw.

Return type:

_ScalarMappable

add_3d_scatter(*, x, y, z, params, discretized, ax=None)

Add a 3D scatter plot.

Parameters:
  • x (ndarray) – x-axis data.

  • y (ndarray) – y-axis data.

  • z (ndarray) – z-axis data.

  • params (PlotParams) – Plot parameters.

  • discretized (bool) – Whether the color map is discretized or not.

  • ax (Axes | Axes3D | None) – Axes on which to draw.

Return type:

_ScalarMappable

add_carto_color_mesh(*, x, y, z, params, ax=None)

Add a pcolormesh on a cartopy map.

Parameters:
Return type:

_ScalarMappable

add_carto_scatter(*, x, y, z, params, discretized, ax=None)

Add a scatter plot on a cartopy map.

Parameters:
  • x (ndarray) – x-axis data.

  • y (ndarray) – y-axis data.

  • z (ndarray) – z-axis data.

  • params (PlotParams) – Plot parameters.

  • discretized (bool) – Whether the color map is discretized or not.

  • ax (Axes | None) – Axes on which to draw.

Return type:

_ScalarMappable

add_color_bar(*, params, mappable)

Add a color bar to the figure.

Parameters:
add_color_box_3d(*, x, y, z, params, ax=None)

Add a pcolormesh on a plot.

Parameters:
Return type:

_ScalarMappable

add_color_mesh(*, x, y, z, params, ax=None)

Add a pcolormesh on a plot.

Parameters:
Return type:

_ScalarMappable

add_color_mesh_3d(*, x, y, z, params, ax=None)

Add a pcolormesh on a plot.

Parameters:
Return type:

_ScalarMappable

add_count_density_mesh(*, x, y, n_vbins, params, ax=None)

Compute and add count density/binning ? from a 2D data.

Parameters:
  • x (ndarray) – x-axis data.

  • y (ndarray) – y-axis data, to compute the count density from.

  • n_vbins (int) – Number of vertical bins for the count density computation

  • params (PlotParams) – Elements properties.

  • ax (Axes | None) – Axes on which to draw.

add_editing(*, x, y, editing, params, ax=None)

Add an editing plot.

Parameters:
add_grid(*, params=None, ax=None)
Parameters:
add_hist_bar(data, params, data_box=None, color_limits=(None, None), mappable=None)

Add a histogram bar to the figure.

Parameters:
add_multi_curves(*, x, y, bin_name, bin_values, params, width=None, ax=None)

Add multiples lines or bars to the provided axes.

Parameters:
  • x (ndarray) – x-axis data.

  • y (ndarray) – y-axis data.

  • bin_name (str) – Label associated to the second binning dimension

  • bin_values (ndarray) – Values of the second binning dimensions

  • params (PlotParams) – Elements properties.

  • width (float | None) – Histogram bars width.

  • ax (Axes | None) – Axes on which to draw.

add_scatter(*, x, y, z, normalized, legend, params, ax=None)

Add a scatter plot.

Parameters:
  • x (ndarray) – x-axis data.

  • y (ndarray) – y-axis data.

  • z (ndarray) – z-axis data.

  • normalized (bool) – Whether provided data were normalized or not.

  • legend (AxeParams) – Legend parameters.

  • params (PlotParams) – Plot’s properties.

  • ax (Axes | None) – Axes on which to draw.

Return type:

tuple[_ScalarMappable, tuple[float, float, float] | None]

Returns:

Plot’s ScalarMappable and optional regression coefficients.

add_single_curve(*, x, y, legend, params, width=None, ax=None)

Add a plot as a line or bar to the provided axes.

Parameters:
  • x (ndarray) – x-axis data.

  • y (ndarray) – y-axis data.

  • legend (str) – Plot’s legend.

  • params (PlotParams) – Plot’s properties.

  • width (float | None) – Histogram bars width.

  • ax (Axes | None) – Axes on which to draw.

add_stat_bar(*, data, params)

Add a statistic bar to the figure.

Parameters:
  • data (DataArray) – Data for which to display statistics.

  • params (AxeParams) – Statistic bar properties.

add_stat_graph(abscissa, mean, std, params)

Add a statistic graph to the figure.

Parameters:
  • abscissa (ndarray) – Abscissa values of the statistic graph to display.

  • mean (ndarray) – Mean values of the statistic graph to display.

  • std (ndarray) – Std values of the statistic graph to display.

  • params (AxeParams) – Element’s parameters.

add_ticks_space(*, space, position)

Add ticks space at the given position.

Parameters:
  • space (float) – Space to add.

  • position (Position) – Position where to add space.

add_trisurf(*, x, y, z, params, discretized, ax=None)

Add a 3D trisurf plot.

Parameters:
  • x (ndarray) – x-axis data.

  • y (ndarray) – y-axis data.

  • z (ndarray) – z-axis data.

  • params (PlotParams) – Plot parameters.

  • discretized (bool) – Whether the color map is discretized or not.

  • ax (Axes | Axes3D | None) – Axes on which to draw.

Return type:

_ScalarMappable

add_watermark(params)

Add watermark.

Parameters:

params (WatermarkParams) – the parameters of the watermark

draw_stat_bar(params)

Draw the statistic bar added to the figure.

Parameters:

params (AxeParams) – Statistic bar properties.

property figure: Figure
get_ax(axtype)

Return the requested axes.

Parameters:

axtype (AxeType) – Type of requested axe.

Return type:

Axes

Returns:

Requested axe.

property main_ax: Axes | GeoAxes
new_color(color=None)

Return color if not used, a new one otherwise.

reset_colors()

Reset list of used colors.

set_axes_params(*, axt, params)

Set the provided axes parameters.

Parameters:
set_bounds(*, extent, ax=None)

Set the graph boundaries.

Parameters:
set_color_used(color)

Add provided color to the list of used colors.

set_features(template, ax=None)

Set additional cto.features.

Parameters:
set_figure_title(params)
Parameters:

params (AxeParams)

set_legends(*, params, force_display=False)

Set the figure legends.

Parameters:
  • params (AxeParams) – Plot parameters.

  • force_display (bool) – Whether to force legend display or not.

set_size(*, width, height)
Parameters:
casys.visualization.figure.compute_inverse_axis_ticks(values)

This function performs the computation of the inverse axis ticks positions for a logarithmic scale, relatively to the original axis values.

Parameters:

values (ndarray) – Values of the original axis to compute the reverse axis ticks position from.

Return type:

tuple[ndarray, ndarray]

Returns:

ticks, labels: ticks positions and labels for the reverse log-scaled axis.

casys.visualization.figure.is_text_property(prop)

Check whether the given property is a valid Text property or not.

Parameters:

prop (str)

Return type:

bool