Skip to content

Commit

Permalink
feat: add a scaled tab to ts index overview (#1401)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbarros authored Jul 31, 2023
1 parent 1325634 commit 14ad4ac
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
17 changes: 15 additions & 2 deletions src/ydata_profiling/report/structure/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,25 @@ def format_tsindex_limit(limit: Any) -> str:
plot_overview_timeseries(config, summary.variables),
image_format=config.plot.image_format,
alt="ts_plot",
name="ts_plot",
name="preview",
anchor_id="ts_plot_overview",
)
timeseries_scaled = ImageWidget(
plot_overview_timeseries(config, summary.variables, scale=True),
image_format=config.plot.image_format,
alt="ts_plot_scaled",
name="scaled",
anchor_id="ts_plot_scaled_overview",
)
ts_tab = Container(
[timeseries, timeseries_scaled],
anchor_id="ts_plot_overview",
name="",
sequence_type="tabs",
)

return Container(
[ts_info, timeseries],
[ts_info, ts_tab],
anchor_id="timeseries_overview",
name="Time Series",
sequence_type="grid",
Expand Down
8 changes: 6 additions & 2 deletions src/ydata_profiling/visualisation/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,13 @@ def plot_overview_timeseries(
config: Settings,
variables: Any,
figsize: tuple = (6, 4),
scale: bool = False,
) -> matplotlib.figure.Figure:
"""Plot an line plot from the data and return the AxesSubplot object.
Args:
series: The data to plot
figsize: The size of the figure (width, height) in inches, default (6,4)
variables: The data to plot.
figsize: The size of the figure (width, height) in inches, default (6,4).
scale: Scale series values between [0,1]. Defaults to False.
Returns:
The TimeSeries lineplot.
"""
Expand All @@ -580,6 +582,8 @@ def plot_overview_timeseries(
for col, data in variables.items():
if all(iter([t == "TimeSeries" for t in data["type"]])):
for i, series in enumerate(data["series"]):
if scale:
series = (series - series.min()) / (series.max() - series.min())
series.plot(
ax=ax,
label=col,
Expand Down

0 comments on commit 14ad4ac

Please sign in to comment.