gerg_plotting.plotting_classes.plotter#

Module Contents#

class gerg_plotting.plotting_classes.plotter.Plotter#

Base class for creating plots of data.

Parameters#

dataData

Data object containing variables to plot

bounds_paddingfloat

Padding to be applied to detected bounds

figmatplotlib.figure.Figure, optional

Matplotlib figure object

axmatplotlib.axes.Axes, optional

Matplotlib axes object

nrowsint

Number of rows in figure, default is 1

cbar_nbinsint

Number of bins for colorbar ticks, default is 5

cbar_kwargsdict

Keyword arguments for colorbar customization

Attributes#

cbarmatplotlib.colorbar.Colorbar

Colorbar object for the plot

add_colorbar(mappable: matplotlib.axes.Axes, var: str | None, divider=None, total_cbars: int = 2) None#

Add colorbar to plot.

Parameters#

mappablematplotlib.axes.Axes

Plot object to create colorbar for

varstr or None

Variable name for colorbar

divideroptional

Axes divider for colorbar positioning

total_cbarsint, optional

Total number of colorbars in plot, default 2

Returns#

matplotlib.colorbar.Colorbar

Created colorbar object

adjust_datetime_labels(rotation=30)#

Adjust datetime labels on x-axis to prevent overlap.

Parameters#

rotationint, optional

Rotation angle for labels if overlap detected, default 30

ax: matplotlib.axes.Axes#
bounds_padding: float#
cbar: matplotlib.colorbar.Colorbar#
cbar_kwargs: dict#
cbar_nbins: int#
data: gerg_plotting.data_classes.data.Data#
fig: matplotlib.figure.Figure#
format_axes(xlabel, ylabel, zlabel=None, invert_yaxis: bool = False) None#

Format plot axes with labels and options.

Parameters#

xlabelstr

Label for x-axis

ylabelstr

Label for y-axis

invert_yaxisbool, optional

Whether to invert y-axis, default False

get_cmap(color_var: str) matplotlib.colors.Colormap#

Get colormap for specified variable.

Parameters#

color_varstr

Name of variable for colormap

Returns#

matplotlib.colors.Colormap

Colormap for variable

get_vars() list#

Get list of all object variables.

Returns#

list

List of variable names

init_figure(fig=None, ax=None, figsize=(6.4, 4.8), three_d=False, geography=False) None#

Initialize figure and axes objects.

Parameters#

figmatplotlib.figure.Figure, optional

Pre-existing figure

axmatplotlib.axes.Axes, optional

Pre-existing axes

figsizetuple, optional

Figure dimensions (width, height)

three_dbool, optional

Whether to create 3D plot

geographybool, optional

Whether to create map projection

Raises#

ValueError

If both three_d and geography are True

nrows: int#
save(filename, **kwargs)#

Save figure to file.

Parameters#

filenamestr

Path to save figure

**kwargs

Additional arguments for savefig

Raises#

ValueError

If no figure exists

show()#

Show all open figures