ogstools.plot.utils module#

ogstools.plot.utils.get_style_cycler(min_number_of_styles, colors=None, linestyles=None)[source]#
Return type:

Cycler

ogstools.plot.utils.justified_labels(points)[source]#

Formats an array of points to a list of aligned str.

Return type:

list[str]

ogstools.plot.utils.label_spatial_axes(axes, x_label='x', y_label='y', spatial_unit='m')[source]#

Add labels to x and y axis.

If given an array of axes, only the outer axes will be labeled.

ogstools.plot.utils.update_font_sizes(axes, fontsize=None)[source]#

Update font sizes of labels and texts.

Parameters:
  • ax – matplotlib axes which should be updated

  • fontsize (float | None) – font size for the labels and ticks

ogstools.plot.utils.get_data_aspect(mesh)[source]#

Calculate the data aspect ratio of a 2D mesh.

Return type:

float

ogstools.plot.utils.get_rows_cols(meshes)[source]#
Return type:

tuple[int, …]

ogstools.plot.utils.get_projection(mesh)[source]#

Identify which projection is used: XY, XZ or YZ.

Parameters:

mesh (UnstructuredGrid) – singular mesh

Returns:

x_id, y_id, projection, mean_normal

Return type:

tuple[int, int, int, ndarray]

ogstools.plot.utils.save_animation(anim, filename, fps)[source]#

Save a FuncAnimation with some codec presets.

Parameters:
  • anim (FuncAnimation) – the FuncAnimation to be saved

  • filename (str) – the name of the resulting file

  • fps (int) – the number of frames per second

Return type:

bool

ogstools.plot.utils.get_cmap_norm(levels, variable)[source]#

Construct a discrete colormap and norm for the variable field.

Return type:

tuple[Colormap, Normalize]

ogstools.plot.utils.contrast_color(color)[source]#

Return black or white - whichever has more contrast to color.

https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color

Return type:

Any

ogstools.plot.utils.padded(ax, x, y)[source]#

Add a padding to x and y towards the axes center.

Return type:

tuple[float, float]

ogstools.plot.utils.color_twin_axes(axes, colors)[source]#