gerg_plotting.plotting_classes.coverage_plot#

Module Contents#

class gerg_plotting.plotting_classes.coverage_plot.Base#

Base class providing common functionality for attribute access and variable management.

Methods#

_has_var(key)

Check if object has a specific variable.

get_vars()

Get list of all object variables/attributes.

__getitem__(key)

Enable dictionary-style access to class attributes.

__setitem__(key, value)

Enable dictionary-style setting of class attributes.

__str__()

Return formatted string representation of class attributes.

get_vars() list#

Get list of all object variables/attributes.

Returns#

list

List of all variable names in the object.

class gerg_plotting.plotting_classes.coverage_plot.Coverage#

Bases: Base

A class for creating and managing coverage representations including body, outline, label, and extent arrows.

Parameters#

body_min_heightfloat

Minimum height for coverage body. Default is 0.25.

body_alphafloat

Transparency of coverage body. Default is 1.

body_linewidthfloat

Line width of coverage body. Default is 1.

body_colorstr or tuple

Fill color of coverage body. Default is ‘none’.

body_hatchstr

Hatch pattern for coverage body. Default is None.

body_hatch_colorstr

Color of hatch pattern. Default is None.

hatch_linewidthfloat

Width of hatch lines. Default is 0.5.

outline_edgecolorstr or tuple

Color of outline. Default is ‘k’.

outline_alphafloat

Transparency of outline. Default is 1.

outline_linewidthfloat

Width of outline. Default is 1.

label_fontsizefloat

Font size for label. Default is 12.

label_background_padfloat

Padding around label background. Default is 2.

label_background_linewidthfloat

Width of label background border. Default is 0.

label_background_alphafloat

Transparency of label background. Default is 1.

label_background_colorfloat

Color of label background. Default is ‘body_color’.

show_arrowsbool

Whether to show extent arrows. Default is True.

Attributes#

bodyRectangle

The main coverage area rectangle.

outlineRectangle

The outline rectangle.

labelText

The coverage label.

extent_arrowsExtentArrows

Arrows showing coverage extent.

add_label_background(text: matplotlib.text.Text)#

Add background to coverage label.

Parameters#

textmatplotlib.text.Text

The text object to add background to.

body: matplotlib.patches.Rectangle#
body_alpha: float#
body_color: str | tuple#
body_hatch: str#
body_hatch_color: str#
body_linewidth: float#
body_min_height: float#
create(xrange, yrange, label, **kwargs)#

Create a new coverage object with specified range and label.

Parameters#

xrangelist

Range of x-axis coverage [start, end].

yrangelist

Range of y-axis coverage [start, end].

labelstr

Label text for the coverage.

**kwargs

Additional keyword arguments for customizing appearance.

Returns#

Coverage

The created coverage object.

extent_arrows: ExtentArrows#
hatch_linewidth: float#
label: matplotlib.text.Text#
label_background_alpha: float#
label_background_color: float#
label_background_linewidth: float#
label_background_pad: float#
label_fontsize: float#
outline: matplotlib.patches.Rectangle#
outline_alpha: float#
outline_edgecolor: str | tuple#
outline_linewidth: float#
plot(ax: matplotlib.axes.Axes, **kwargs)#

Plot the coverage on given axes.

Parameters#

axmatplotlib.axes.Axes

The axes to plot on.

**kwargs

Additional keyword arguments for plotting.

show_arrows: bool#
class gerg_plotting.plotting_classes.coverage_plot.CoveragePlot#

Bases: Base

A class for creating and managing plots showing multiple coverage areas.

Parameters#

figFigure, optional

Matplotlib figure object.

axAxes, optional

Matplotlib axes object.

figsizetuple, optional

Size of the figure (width, height).

horizontal_paddingfloat

Padding on left and right of plot. Default is 0.25.

vertical_paddingfloat

Padding on top and bottom of plot. Default is 0.75.

xlabelslist

Labels for x-axis ticks.

ylabelslist

Labels for y-axis ticks.

cmapstr or Colormap

Colormap for coverage areas.

coverage_color_defaultstr or tuple

Default color for coverages if specified.

Attributes#

color_iteratoritertools.cycle

Iterator for cycling through colors.

coverageslist

List of Coverage objects.

gridGrid

Grid object for the plot.

plotting_kwargsdict

Default keyword arguments for plotting.

add_coverage(xrange, yrange, label=None, **kwargs)#

Add a new coverage area to the plot.

Parameters#

xrangelist or scalar

Range or single value for x-axis coverage.

yrangelist or scalar

Range or single value for y-axis coverage.

labelstr, optional

Label for the coverage area.

**kwargs

Additional keyword arguments for coverage customization.

Raises#

ValueError

If xrange and yrange are not the same length.

add_grid(show_grid: bool)#

Add grid to the plot if requested.

Parameters#

show_gridbool

Whether to show the grid.

ax: matplotlib.axes.Axes#
cmap: str | matplotlib.colors.Colormap#
color_iterator: itertools.cycle#
coverage_color()#

Get the next color for a coverage area.

Returns#

tuple or str

RGBA color tuple or specified default color.

coverage_color_default#
coverages: list[Coverage]#
custom_ticks(labels, axis: str)#

Set custom tick labels for specified axis.

Parameters#

labelslist

List of tick labels.

axisstr

Axis to customize (‘x’ or ‘y’).

fig: matplotlib.figure.Figure#
figsize: tuple#
grid: Grid#
handle_ranges(xrange, yrange)#

Convert string labels to numeric indices for plotting.

Parameters#

xrangelist

Range values for x-axis.

yrangelist

Range values for y-axis.

Returns#

tuple

Processed (xrange, yrange) with numeric values.

horizontal_padding: float#
init_figure() None#

Initialize figure and axes if not provided.

plot(show_grid=True)#

Create the complete coverage plot.

Parameters#

show_gridbool, optional

Whether to show grid lines. Default is True.

plot_coverages()#

Plot all coverage areas on the figure.

plotting_kwargs: dict#
save(filename, **kwargs)#

Save the current figure to a file.

Parameters#

filenamestr

Path to save the figure.

**kwargs

Additional keyword arguments passed to savefig.

Raises#

ValueError

If no figure exists to save.

set_padding()#

Set plot limits with padding.

set_up_plot(show_grid: bool = True)#

Configure the plot with all necessary components.

Parameters#

show_gridbool, optional

Whether to show grid lines. Default is True.

show(**kwargs)#

Display the plot.

Parameters#

**kwargs

Additional keyword arguments passed to plt.show().

vertical_padding: float#
xlabels: list#
ylabels: list#
class gerg_plotting.plotting_classes.coverage_plot.ExtentArrows#

Bases: Base

A class for managing and drawing arrows that indicate coverage extents.

Parameters#

arrow_facecolorstr or tuple

Color of arrow fill. Use ‘coverage_color’ to match coverage color. Default is ‘black’.

arrow_edgecolorstr or tuple

Color of arrow edges. Default is ‘black’.

arrow_tail_widthfloat

Width of arrow tail. Default is 0.05.

arrow_head_widthfloat

Width of arrow head. Default is 0.12.

arrow_zorderfloat

Z-order for arrow drawing. Default is 2.9.

arrow_linewidthfloat

Width of arrow lines. Default is 0.

arrow_text_paddingfloat

Padding between arrow and text. Default is 0.05.

Attributes#

left_arrowFancyArrow

Arrow object for left extent.

right_arrowFancyArrow

Arrow object for right extent.

top_arrowFancyArrow

Arrow object for top extent.

bottom_arrowFancyArrow

Arrow object for bottom extent.

add_range_arrows(ax: matplotlib.axes.Axes, text: matplotlib.text.Text, rect: matplotlib.patches.Rectangle)#

Add arrows indicating the range of coverage.

Parameters#

axmatplotlib.axes.Axes

The axes to draw arrows on.

textmatplotlib.text.Text

Text object to position arrows around.

rectmatplotlib.patches.Rectangle

Rectangle representing coverage area.

arrow_edgecolor: str | tuple#
arrow_facecolor: str | tuple#
arrow_head_width: float#
arrow_linewidth: float#
arrow_tail_width: float#
arrow_text_padding: float#
arrow_zorder: float#
bottom_arrow: matplotlib.patches.FancyArrow#
calculate_arrow_length(ax: matplotlib.axes.Axes, rect, text_left, text_right)#

Calculate the lengths needed for extent arrows.

Parameters#

axmatplotlib.axes.Axes

The axes containing the arrows.

rectRectangle

Rectangle object representing coverage area.

text_leftfloat

Left boundary of text.

text_rightfloat

Right boundary of text.

Returns#

tuple

(left_arrow_length, right_arrow_length)

left_arrow: matplotlib.patches.FancyArrow#
right_arrow: matplotlib.patches.FancyArrow#
top_arrow: matplotlib.patches.FancyArrow#
class gerg_plotting.plotting_classes.coverage_plot.Grid#

Bases: Base

A class for managing and drawing grid lines on a plot.

Parameters#

xlabelslist

Labels for x-axis grid lines.

ylabelslist

Labels for y-axis grid lines.

grid_linewidthfloat, optional

Width of grid lines. Default is 1.

grid_linestylestr, optional

Style of grid lines. Default is ‘–‘.

grid_colorstr or tuple, optional

Color of grid lines. Default is ‘black’.

grid_zorderfloat, optional

Z-order of grid lines. Default is 1.15.

add_grid(ax, **grid_kwargs)#

Add complete grid to the plot with both horizontal and vertical lines.

Parameters#

axmatplotlib.axes.Axes

The axes to draw the grid on.

**grid_kwargs

Additional keyword arguments for grid customization including: - grid_linewidth: Width of grid lines - grid_color: Color of grid lines - grid_linestyle: Style of grid lines

add_hlines(ax: matplotlib.axes.Axes, y_values, **kwargs)#

Add horizontal lines to the plot.

Parameters#

axmatplotlib.axes.Axes

The axes to draw the lines on.

y_valuesarray-like

Y-coordinates where horizontal lines should be drawn.

**kwargs

Additional keyword arguments passed to axhline.

add_vlines(ax: matplotlib.axes.Axes, x_values, **kwargs)#

Add vertical lines to the plot.

Parameters#

axmatplotlib.axes.Axes

The axes to draw the lines on.

x_valuesarray-like

X-coordinates where vertical lines should be drawn.

**kwargs

Additional keyword arguments passed to axvline.

grid_color: str | tuple#
grid_linestyle: str#
grid_linewidth: float#
grid_zorder: float#
xlabels: list#
ylabels: list#