Skip to content

Add xticks parameter for plot_periodogram, clip frequencies to be >= 1 #706

Merged
merged 2 commits into from
May 25, 2022

Conversation

Mr-Geekman
Copy link
Contributor

@Mr-Geekman Mr-Geekman commented May 23, 2022

IMPORTANT: Please do not create a Pull Request without creating an issue first.

Before submitting (must do checklist)

  • Did you read the contribution guide?
  • Did you update the docs? We use Numpy format for all the methods and classes.
  • Did you write any new necessary tests?
  • Did you update the CHANGELOG?

Type of Change

  • Examples / docs / tutorials / contributors update
  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves an existing feature)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Proposed Changes

Look #703.

Related Issue

#703.

Closing issues

Closes #703.

@Mr-Geekman Mr-Geekman added the enhancement New feature or request label May 23, 2022
@Mr-Geekman Mr-Geekman self-assigned this May 23, 2022
@Mr-Geekman
Copy link
Contributor Author

Example script:

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

from etna.analysis import plot_periodogram
from etna.datasets import TSDataset


def main():
    df = pd.read_csv("examples/data/example_dataset.csv", parse_dates=["timestamp"])
    df_wide = TSDataset.to_dataset(df)
    df_wide.iloc[:3, 0] = np.NaN
    # df_wide.iloc[10:20, 1] = np.NaN
    ts = TSDataset(df=df_wide, freq="D")

    # per-segment
    plot_periodogram(ts=ts, period=30, amplitude_aggregation_mode="per-segment")
    plt.savefig("periodogram_per_segment_month")

    plot_periodogram(ts=ts, period=365.25, amplitude_aggregation_mode="per-segment")
    plt.savefig("periodogram_per_segment_year")

    year_ticks = [1, 2, 4, 6, 12, 26, 52, 104]
    plot_periodogram(ts=ts, period=365.25, amplitude_aggregation_mode="per-segment", xticks=year_ticks)
    plt.savefig("periodogram_per_segment_year_with_ticks")

    # aggregated
    plot_periodogram(ts=ts, period=30, amplitude_aggregation_mode="mean", periodogram_params=dict(scaling="spectrum"))
    plt.savefig("periodogram_mean_month")

    plot_periodogram(
        ts=ts, period=365.25, amplitude_aggregation_mode="mean", periodogram_params=dict(scaling="spectrum")
    )
    plt.savefig("periodogram_mean_year")

    plot_periodogram(
        ts=ts,
        period=365.25,
        amplitude_aggregation_mode="mean",
        periodogram_params=dict(scaling="spectrum"),
        xticks=year_ticks,
    )
    plt.savefig("periodogram_mean_year_with_ticks")


if __name__ == "__main__":
    main()

periodogram_per_segment_month:
periodogram_per_segment_month

periodogram_per_segment_year:
periodogram_per_segment_year

periodogram_per_segment_year_with_ticks:
periodogram_per_segment_year_with_ticks

periodogram_mean_month:
periodogram_mean_month

periodogram_mean_year:
periodogram_mean_year

periodogram_mean_year_with_ticks:
periodogram_mean_year_with_ticks

@github-actions
Copy link

github-actions bot commented May 23, 2022

🚀 Deployed on https://deploy-preview-706--etna-docs.netlify.app

@github-actions github-actions bot temporarily deployed to pull request May 23, 2022 15:45 Inactive
@martins0n martins0n self-requested a review May 25, 2022 07:43
Copy link
Contributor

@martins0n martins0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@martins0n martins0n merged commit 91edf5b into master May 25, 2022
@martins0n martins0n deleted the issue-703 branch May 25, 2022 08:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fixes for plot_periodogram
2 participants