deepcave.utils.styled_plot

# StyledPlot

This module provides utilities to customize functions from the matplotlib. Plots can be created and different parameters of the plots can be defined.

## Classes
  • StyledPlot: Overwrites default settings from matplotlib.pyplot.

## Constants

FIG_WIDTH: float FIG_HEIGHT: float

Classes

StyledPlot()

Overwrites default settings from matplotlib.pyplot.

class deepcave.utils.styled_plot.StyledPlot[source]

Bases: object

Overwrites default settings from matplotlib.pyplot.

If a function is not overwritten, the default function will be used.

Properties

pltModule(“matplotlib.pyplot”)

The matplotlib plot. The style used is seaborn.

__getattr__(name)[source]

Make sure self.plt is accessed directly.

Return type:

Any

boxplot(values, positions, color, widths=0.5)[source]

Create a boxplot on a matplotlib plot.

Parameters:
  • values (np.ndarray) – Values to create the boxplot.

  • positions (ArrayLike) – The position of the boxplot.

  • color (str) – The color of the boxes as well as other elements in the plot.

  • widths (float, optional) – The width of the boxes. Default is 0.5.

Return type:

None

figure(cols=1, rows=1, dpi=200)[source]

Create a new figure using the input values.

Parameters:
  • cols (int, optional) – The number of the columns. Default is 1.

  • rows (int, optional) – The number of the rows. Default is 1.

  • dpi (int, optional) – The dots per inches (dpi). Default is 200.

Returns:

The figure created with the input information.

Return type:

plt.Figure

get_color(id)[source]

Get the color from color palette based on the given id.

Parameters:

id (int) – id for retrieving a specific color.

Returns:

The color from the color palette.

Return type:

str

legend(cols=1, loc=None, title=None, outside=False)[source]

Customize and add a legend to a matplot plot.

Customize the placement and appearance of the legend.

Parameters:
  • cols (int, optional) – The number of the columns. Default is 1

  • loc (Optional[str], optional) – The location of the legend. Default is None.

  • title (Optional[str], optional) – The title for the legend. Default is None.

  • outside (bool, optional) – Determines if a legend is placed outside of plot area. Default is False.

Return type:

None

render()[source]

Render the Styled Plot for displaying.

Returns:

The rendered plot.

Return type:

str

save_figure(filename)[source]

Save the figure/plot at the given filename.

Parameters:

filename (Union[str, Path]) – The name of the file the plot will be saved at.

Return type:

None

xlim(xmin, xmax)[source]

Set the x-axis limits with a margin of a matplotlib plot.

Parameters:
  • xmin (Union[float, int]) – The lower x-axis limit.

  • xmax (Union[float, int]) – The upper x-axis limit.

Return type:

None

ylim(ymin, ymax, margin=True)[source]

Set the y-axis limit of a matplotlib plot.

Parameters:
  • ymin (Union[float, int]) – The lower y-axis limit.

  • ymax (Union[float, int]) – The upper y-axis limit.

  • margin (bool, optional) – Determines whether a margin should be added to the limits. Default is True.

Return type:

None