osos.utilities.plotting.Plotting

class Plotting[source]

Bases: object

OSOS plotting utilities for auto-plotting of usage data.

Methods

auto_plot(metric[, cumulative, ylabel, ...])

Auto plot a single metric for all osos datasets in the osos source_dir path

plot_metric(df, metric[, cumulative, ...])

Plot a osos metric from an osos dataframe.

Attributes

ALIASES

static plot_metric(df, metric, cumulative=False, ylabel=None, figsize=(10, 5), save_path=None, show=True, close=True)[source]

Plot a osos metric from an osos dataframe.

Parameters:
  • df (pd.DataFrame) – OSOS data timeseries dataframe, likely from the repository DATA_DIR

  • metric (str) – Metric to plot in the dataframe. Must be one of the column titles.

  • cumulative (bool) – Flag to plot the cumulative sum of the metric.

  • ylabel (str) – Optional y axis label. If None the metric will be used.

  • save_path (str | None) – Filepath to save figure to (optional).

  • show (bool) – Flag to show / display figure (should be false for automated calls)

  • close (bool) – Flag to close figure after saving/showing

Returns:

ax (matplotlib.axes._subplots.AxesSubplot) – AxesSubplot object generated by matplotlib

classmethod auto_plot(metric, cumulative=False, ylabel=None, source_dir='/home/runner/work/osos/osos/data', save_dir='/home/runner/work/osos/osos/plots')[source]

Auto plot a single metric for all osos datasets in the osos source_dir path

Parameters:
  • metric (str) – Metric to plot in the dataframe. Must be one of the column titles.

  • cumulative (bool) – Flag to plot the cumulative sum of the metric.

  • ylabel (str) – y axis label for all plots. Can include format string {name} that will be replaced with the repo name from the data filename. If None, the ylabel will just be the metric.

  • source_dir (str) – Directory to look for osos csv’s. This function will try to plot the desired metric from all csv’s in this directory.

  • save_dir (str) – Directory to save the plots. Will be created if it doesnt exist.