Skip to content

Commit

Permalink
[ENH] Implementing plot title for plot_series (#4038)
Browse files Browse the repository at this point in the history
Adds an optional "title" parameter for the plot_series funcion in utils.

Changes:
The function plot_series now has one more parameter: suptitle (default value is None) to which user can give the title of the plot or figure.
  • Loading branch information
arnavrneo committed Jan 5, 2023
1 parent 384e80d commit 286e1af
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sktime/utils/plotting.py
Expand Up @@ -23,6 +23,7 @@ def plot_series(
labels=None,
markers=None,
colors=None,
title=None,
x_label=None,
y_label=None,
ax=None,
Expand All @@ -41,6 +42,8 @@ def plot_series(
The length of the list has to match with the number of series.
colors: list, default = None
The colors to use for plotting each series. Must contain one color per series
title: str, default = None
The text to use as the figure's suptitle
pred_interval: pd.DataFrame, default = None
Output of `forecaster.predict_interval()`. Contains columns for lower
and upper boundaries of confidence interval.
Expand Down Expand Up @@ -138,6 +141,10 @@ def format_fn(tick_val, tick_pos):
ax.xaxis.set_major_formatter(FuncFormatter(format_fn))
ax.xaxis.set_major_locator(MaxNLocator(integer=True))

# Set the figure's title
if title is not None:
fig.suptitle(title, size="xx-large")

# Label the x and y axes
if x_label is not None:
ax.set_xlabel(x_label)
Expand Down

0 comments on commit 286e1af

Please sign in to comment.