sattoolbox.plots.raw_material package

Subpackages

Submodules

sattoolbox.plots.raw_material.fm_plots module

Plot functions from Felix Micus.

@author: FM

sattoolbox.plots.raw_material.fm_plots.Lineplot(data_left, data_right=None, title='Title', ylim1=None, ylim2=None, ylabel=['left', 'right'], fmt='png', save_dir=None, aux_lines=None, x_rotation=45)[source]
data_leftDataFrame

DESCRIPTION. Needs to have a DateTimeIndex

data_rightTYPE, optional

Needs to have a DateTimeIndex.

titleString, optional

Title for the plot. Is also used for the filename. So no ‘' or ‘.’ etc allowed

ylim1tuple, list with len==2 or an int, float, optional

Parameter to be passed to ax.set_ylim(). Either a tuple, list with len==2 or an int, float, or None allowed. The default is None.

ylim1tuple, list with len==2 or an int, float, optional

Parameter to be passed to ax.set_ylim(). Either a tuple, list with len==2 or an int, float, or None allowed. The default is None.

ylabelString, optional

Tuple or list with len==2 to be used for left and right label. The default is [“left”,”right”].

fmtString or list of Strings, optional

Format(s) to be used in savefig. If an iterable of strings is passed, the figure will be saved in all formats. The default is “png”.

save_dirString, optional

The directory in which to save the figure. If path is None, the figure will not be saved. The default is None.

aux_linespd.DataFrame, pd.Series, list or dict, optional

This will plot vertical or horizontal lines into the plot. Lines that have a numeric value will be treated as horizontal lines (of the left axis), lines that have a Datetime locator will be plotted as vertical lines. Wrong types will be ignored and a Warning will be printed. The default is None.

x_rotationint, float, optional

Degress to rotate x-axis labels (dates). The default is 45.

figmatplotlib.Figure

Figure object of the created plot

ax1: matplotlib.Axes

Axes (left axis) object of the created plot

sattoolbox.plots.raw_material.fm_plots.bar_plot(data_set, *, data_right=None, ylabel=None, title=None, xlabel=None, legend=True, colors=None, ax=None)[source]

Creates a bar plot with grouped bars. Each column of the data_set represents a bar per group, Each row represents a new group. Row index is used as xlabel Not complete for right axis plot Parameters ———- data_set : DataFrame

DataFrame with the bar data. Each column represents one bar, each row is a new bar group.

  • : Forcing following parameters to be named

    DESCRIPTION.

ylabelString, optional

Label for y-axis. The default is ‘mass flow in kg/s’.

titleString, optional

Plot title. The default is ‘mass flow distribution’.

legendboolean, optional

if a legend is shown. The default is True.

colorsarrays, optional

array representing the color for each bar. The default is None.

axmatplotlib Axes, optional

Can be passed to plot on an existing axis. The default is None.

axAxes

Returns Axes object.

plt.gcf()

Current figure of matplotlib.

sattoolbox.plots.raw_material.fm_plots.example()[source]

Run examples of the functions defined in this module. There are two ways of using this example:

  • import sattoolbox as stb and call stb.plots.fm_plots.example()

  • directly run this file like a script (this works, because “if __name__ == ‘__main__’:” runs this example)

Return type:

None.

sattoolbox.plots.raw_material.fm_plots.set_plot_style(style)[source]

Sets the plot style using:

plt.style.use(“style”)

Parameters:

style (String) – A plot style that can be found in the path. Default is “seaborn-v0_8-whitegrid”

Return type:

None.

sattoolbox.plots.raw_material.fm_plots.set_resolution(reso)[source]

Sets the resolution of the plot file when saved

Parameters:

reso (int) – Integer for the dpi of the plot file to be saved (dpi).

Return type:

None.

sattoolbox.plots.raw_material.jz_plots module

Created on Tue May 28 10:01:19 2024

@author: user

sattoolbox.plots.raw_material.jz_plots.example()[source]

Run examples of the functions defined in this module. There are two ways of using this example:

  • import sattoolbox as stb and call stb.plots.fm_plots.example()

  • directly run this file like a script (this works, because “if __name__ == ‘__main__’:” runs this example)

Return type:

None.

sattoolbox.plots.raw_material.jz_plots.plot_curves(data, t_start=None, t_delta=None, resample=None, rolling=None, variables_ax1: list | None = None, variables_ax2: list | None = None, ylim_ax1=None, ylim_ax2=None, colorsdict='black', stylesdict='solid', alpha=1, cycler_ax1=None, cycler_ax2=None, layout='constrained', layout_kwargs: dict | None = None, title=None, ylabel_ax1=None, ylabel_ax2=None, xlabel=None, annotate_curves=False, figsize=(10, 6), **kwargs)[source]

Plot curves from a DataFrame. Features: - Plot curves on primary or secondary axis (specified via “variables_ax1”

and “variables_ax2” or inferred automatically, if given)

  • use dictionaries to define colors and styles for variables. This is useful to ensure that the same physical quantities are plotted in the same color and the same units / positions of measurement / … in the same style in the figure. Or you choose to provide a plt.cycler directly (which overrides the color and styles dictionaries).

  • (optional) select timerange that shall be used for plotting via t_start and t_range

  • (optional) resample data (mean value for period)

  • (optional) apply rolling mean on data

  • (optional) annotation of curves (this functionality probably needs improvement for better placement)

Parameters:
  • data (pd.DataFrame) – DataFrame with simulation results

  • t_start (datetime.datetime) – starting time of the plot, default=None (then plot will start at min(data_dict[data_dict.keys()[0]].index()) )

  • t_delta (datetime.timedelta or str) – range of the time axis, either timedelta or string like ‘7D’, ‘1H’; default=None (then plot will go up to the end of data)

  • resample (string) – Period for resampling the data (mean), default=None, choose a valid resampling string such as ‘D’, ‘H’ or ‘15T’

  • rolling (string) – Window for rolling mean, default=None, choose a valid window string such as ‘D’, ‘H’ or ‘15T’

  • variables_ax1 (list of strings) – Variables to be plotted on primary axis, default []

  • variables_ax2 (list of strings) – Variables to be plotted on secondary axis, default []

  • ylim_ax1 (tuple of numbers) – Limits of the primary y-axis.

  • ylim_ax2 (tuple of numbers) – Limits of the secondary y-axis.

  • colorsdict (dict {'variable_name':'color'} or str) – Single color string or dict of colors to be used for plotting the curves; default=’black’

  • stylesdict (dict {'unit_name':'style'} or str) – Single style string or dict of styles to be used for plotting the curves. Note that matching of unit_names is done from the end of the variable names; default=’black’

  • alpha (float) – Number in [0;1] to indicate transparency of curves.

  • cycler_ax1 (Cycler) – Cycler object for colors and style properties on primary axis. Can be constructed via matplotlib.pyplot.cycler(color=[…], line_style=[…]); Using this option overrides colorsdict, stylesdict and alpha.

  • cycler_ax2 (Cycler) – Cycler object for secondary axis.

  • layout (str) – Layout option for matplotlib.figure.Figure.set_layout_engine(). Default is ‘constrained’

  • layout_kwargs (dict) – Additional keyword arguments to be passed to matplotlib.figure. Figure.set_layout_engine(). Default is {}.

  • titel (str) – Title used as supertitle of the figure. Default is ‘None’.

  • y_label_ax1 (str) – Label for the primary axis. Default is ‘None’, which lets this function try to infer the label from the variable names.

  • y_label_ax2 (str) – Label for the secondary axis. Default is ‘None’, which lets this function try to infer the label from the variable names.

  • x_label (str) – Label for the x-axis of the plot. Default is ‘None’, which means no label will be given to the x-axis.

  • annotate_curves (Boolean) – Wether curve labels shall be added as annotation to the curves. Default=False

  • figsize (tuple of numbers) – Size of the figure. Default is (10,6).

  • kwargs (dict) – additional keyword arguments with standard plot options, default={}

Returns:

  • plot_data (pd.DataFrame) – All data in the plot.

  • fig (matplotlib.figure.Figure) – Figure that was drawn

Module contents

Import Modules, that hold functions for the users of sattoolbox