:py:mod:`mlair.plotting.abstract_plot_class` ============================================ .. py:module:: mlair.plotting.abstract_plot_class .. autoapi-nested-parse:: Abstract plot class that should be used for preprocessing and postprocessing plots. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: mlair.plotting.abstract_plot_class.AbstractPlotClass Attributes ~~~~~~~~~~ .. autoapisummary:: mlair.plotting.abstract_plot_class.__author__ mlair.plotting.abstract_plot_class.__date__ .. py:data:: __author__ :annotation: = Lukas Leufen .. py:data:: __date__ :annotation: = 2021-04-13 .. py:class:: AbstractPlotClass(plot_folder, plot_name, resolution=500, rc_params=None) Abstract class for all plotting routines to unify plot workflow. Each inheritance requires a _plot method. Create a plot class like: .. code-block:: python class MyCustomPlot(AbstractPlotClass): def __init__(self, plot_folder, *args, **kwargs): super().__init__(plot_folder, "custom_plot_name") self._data = self._prepare_data(*args, **kwargs) self._plot(*args, **kwargs) self._save() def _prepare_data(*args, **kwargs): return data def _plot(*args, **kwargs): The save method is already implemented in the AbstractPlotClass. If special saving is required (e.g. if you are using pdfpages), you need to overwrite it. Plots are saved as .pdf with a resolution of 500dpi per default (can be set in super class initialisation). Methods like the shown _prepare_data() are optional. The only method required to implement is _plot. If you want to add a time tracking module, just add the TimeTrackingWrapper as decorator around your custom plot class. It will log the spent time if you call your plotting without saving the returned object. .. code-block:: python @TimeTrackingWrapper class MyCustomPlot(AbstractPlotClass): pass Let's assume it takes a while to create this very special plot. >>> MyCustomPlot() INFO: MyCustomPlot finished after 00:00:11 (hh:mm:ss) .. py:method:: __del__(self) .. py:method:: _plot(self, *args) :abstractmethod: Abstract plot class needs to be implemented in inheritance. .. py:method:: _save(self, **kwargs) Store plot locally. Name of and path to plot need to be set on initialisation. .. py:method:: _update_rc_params(self) .. py:method:: _get_sampling(sampling, pos=1) :staticmethod: .. py:method:: get_dataset_colors() :staticmethod: Standard colors used for train-, val-, and test-sets during postprocessing