Skip to content

Commit

Permalink
fix(plot-series): remove label from arguments and set it with kwargs
Browse files Browse the repository at this point in the history
If `label` is not in the kwargs, set the default value as the column
name. Same principle is applied for `lw` and `linewidth`.
  • Loading branch information
Axel Fahy committed Oct 31, 2019
1 parent 2e52211 commit 556781f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ As of *v0.2*, plots are not yet tested in the travis build.
* ADD: Function ``set_thousands_separator`` to add thousand separator and set the number of decimals on x and/or y ticks.
* ADD: Option to define x axis in ``plot_predictions`` function.
* FIX: Cast columns to string in ``normalization_pd`` function.
* FIX: Add possibility to define custom label in ``plot_series`` function using the kwargs instead of an argument.
* 0.2.3
* ADD: Function ``normalization_pd`` to normalize a DataFrame.
* ADD: Function ``plot_correlation`` to plot the correlation of variables in a DataFrame.
Expand Down
10 changes: 9 additions & 1 deletion bff/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,15 @@ def plot_series(df: pd.DataFrame, column: str, groupby: Union[str, None] = None,

x = df_plot.index

ax.plot(x, df_plot, label=column, color=color, lw=2, **kwargs)
# If the label is not provided, set the column as label.
if 'label' not in kwargs:
kwargs['label'] = column

# Set default linewidth if none of the possible arguments are provided.
if not any(k in kwargs for k in ['lw', 'linewidth']):
kwargs['lw'] = 2

ax.plot(x, df_plot, color=color, **kwargs)

# With sem (standard error of the mean).
sem_alpha = 0.3
Expand Down

0 comments on commit 556781f

Please sign in to comment.