sattoolbox.plots.raw_material.internals package

Submodules

sattoolbox.plots.raw_material.internals.plot_utils module

Created on Tue Aug 9 14:43:08 2022

Helper functions for plotting from Felix Micus (used in fm_plots)

@author: FM

sattoolbox.plots.raw_material.internals.plot_utils.is_iterable_of_strings(obj)[source]

Check whether the passed object is an iterable of strings with a white list. If True, it is an iterable of strings, if False, it might not be, but could be. isinstance(obj, (list, tuple, set, frozenset)) and all(isinstance(item, str) for item in obj)

Parameters:

obj (Object) – DESCRIPTION.

Returns:

Whether the passed objet is on the white list of iterabel Strings.

Return type:

Boolean

sattoolbox.plots.raw_material.internals.plot_utils.label_line(line, ax, label, color='black', size=10, position=0.5, offset=None, verticalalignment='bottom')[source]
Parameters:
  • line (matplotlib.lines.Line2D object) – The line to which the label will be attached.

  • ax (matplotlib.axes.Axes object) – The axes on which the line is plotted.

  • label (str) – The text to be displayed as the label.

  • color (str, optional) – The color of the text (default is ‘black’).

  • size (float, optional) – The font size of the text (default is 10).

  • position (float, optional) – The relative position along the line where the label will be placed, represented as a fraction of the line’s total length (default is 0.5, indicating the middle of the line).

  • offset (numerical, optional) – Offset of the label from the line (The offset will be place perpendicular from the point that is labeled). The direction of the offset depends on the defined vertical aligntment. Labels above the line will be offset up, labels below the line will be offset down. The default is None.

  • verticalalignment (String, optional) – vertival alignment of label. Choice of “bottom”, “baseline”, “center”, “top”. The default is “bottom”.

Returns:

text – The text object representing the label.

Return type:

matplotlib.text.Text object

Example

import matplotlib.pyplot as plt import numpy as np

x = np.linspace(0, 10, 100) y = np.sin(x) fig, ax = plt.subplots() ax.plot(x, y) label_line(line=ax.lines[0], ax=ax, label=’Peak’, color=’red’, size=12, position=0.75) plt.show()

sattoolbox.plots.raw_material.internals.plot_utils.scale_datetime_axis(ax, start_time, end_time, style='tight', label_style='shortname', minor_labels=True, year=False)[source]

Manually scale and label the datetime axis of a plot with a datetime x-Axis. Works for Periods from 1/2 a day to >2 years.

Parameters:
  • ax (Axes Obejct) – Axes object on which to scale the x-axis.

  • start_time (Datetime) – Starting value (left limit of x-axis).

  • end_time (Datetime) – End value (right limit of x-axis).

  • style (String, optional) – Style for the placement of the labels. Implemented are “wide” and “tight”. The default is “tight”.

  • label_style (String, optional) –

    Style to represent the dates for month and day of week. Implemented are: “shortname”: Sep, Oct, Tue, Mon, “name”: April, August, Monday “number”: 02. , 06.

    The default is “shortname”.

  • minor_labels (Boolean, optional) – If minor ticks should get labels. The default is True.

  • year (Boolean, optional) – If the year should be added to dates. The default is False.

Returns:

DESCRIPTION.

Return type:

bool

Module contents