Visualization Utilities

Functions

TStrends provides utility functions for visualizing trend labels on time series data.

tstrends.visualization.plot_trend_labels(time_series_list, labels, title=None, title_size=12)[source]

Simple visualization of the time series series with trend labels.

Creates a matplotlib plot showing the time series series with colored backgrounds indicating the trend labels. Uptrends are shown in green, downtrends in brown.

Parameters:
  • time_series_list (list[float]) – The time series series data points.

  • labels (list[int]) – Trend labels (-1 for downtrend, 1 for uptrend).

  • title (str, optional) – Title for the plot. Defaults to None.

  • title_size (int, optional) – Font size for the plot title. Defaults to 12.

Return type:

None

Example

>>> time series = [100.0, 101.0, 99.0, 98.0]
>>> labels = [1, 1, -1, -1]
>>> plot_trend_labels(time series, labels, "Time series Trends")

Note

This function uses matplotlib’s pyplot interface and will display the plot immediately using plt.show().

tstrends.visualization.plot_trend_labels_with_gradation(time_series_list, labels, title=None, title_size=12, normalize=True)[source]

Visualization of time series with trend labels showing gradation based on label intensity.

Creates a matplotlib plot showing the time series with colored backgrounds indicating trend labels. Uptrends are shown in green, downtrends in brown. The color intensity indicates the strength of the trend, with stronger trends having more saturated colors.

Parameters:
  • time_series_list (list[float]) – The time series data points.

  • labels (list[float]) – Trend labels with values. Can be any range of values.

  • title (str, optional) – Title for the plot. Defaults to None.

  • title_size (int, optional) – Font size for the plot title. Defaults to 12.

  • normalize (bool, optional) – Whether to normalize labels to [-1, 1] range. Defaults to True.

Return type:

None

Example

>>> time_series = [100.0, 101.0, 99.0, 98.0]
>>> labels = [0.5, 0.8, -0.3, -0.9]
>>> plot_trend_labels_with_gradation(time_series, labels, "Time Series Trends with Gradation")

Note

This function uses matplotlib’s pyplot interface and will display the plot immediately using plt.show().