Skip to content

Conversation

@csrgxtu
Copy link

@csrgxtu csrgxtu commented Aug 1, 2024

when you use adtk==0.6.2 and plot the data, you will get following, that's because the matplotlib which is required by adtk installed don't have seaborn-whitegrid in recent versions. for styles available, you can refer: https://matplotlib.org/stable/gallery/style_sheets/style_sheets_reference.html

image

from adtk.visualization import plot
from matplotlib import style
plot(s_train) # s_train is loaded before.

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
File ~/.pyenv/versions/3.12.1/envs/ad/lib/python3.12/site-packages/matplotlib/style/core.py:137, in use(style)
    136 try:
--> 137     style = _rc_params_in_file(style)
    138 except OSError as err:

File ~/.pyenv/versions/3.12.1/envs/ad/lib/python3.12/site-packages/matplotlib/__init__.py:870, in _rc_params_in_file(fname, transform, fail_on_error)
    869 rc_temp = {}
--> 870 with _open_file_or_url(fname) as fd:
    871     try:

File ~/.pyenv/versions/3.12.1/lib/python3.12/contextlib.py:137, in _GeneratorContextManager.__enter__(self)
    136 try:
--> 137     return next(self.gen)
    138 except StopIteration:

File ~/.pyenv/versions/3.12.1/envs/ad/lib/python3.12/site-packages/matplotlib/__init__.py:847, in _open_file_or_url(fname)
    846 fname = os.path.expanduser(fname)
--> 847 with open(fname, encoding='utf-8') as f:
    848     yield f

FileNotFoundError: [Errno 2] No such file or directory: 'seaborn-whitegrid'

The above exception was the direct cause of the following exception:

OSError                                   Traceback (most recent call last)
Cell In[2], line 3
      1 from adtk.visualization import plot
      2 from matplotlib import style
----> 3 plot(s_train)

File ~/.pyenv/versions/3.12.1/envs/ad/lib/python3.12/site-packages/adtk/visualization/_visualization.py:201, in plot(ts, anomaly, curve_group, ts_linewidth, ts_color, ts_alpha, ts_marker, ts_markersize, match_curve_name, anomaly_tag, anomaly_color, anomaly_alpha, anomaly_marker, anomaly_markersize, freq_as_period, axes, figsize, legend)
     35 """Plot time series and/or anomalies.
     36 
     37 Parameters
   (...)
    198 
    199 """
    200 # setup style
--> 201 plt.style.use("seaborn-whitegrid")
    203 # initialize color generator
    204 color_generator = ColorGenerator()

File ~/.pyenv/versions/3.12.1/envs/ad/lib/python3.12/site-packages/matplotlib/style/core.py:139, in use(style)
    137         style = _rc_params_in_file(style)
    138     except OSError as err:
--> 139         raise OSError(
    140             f"{style!r} is not a valid package style, path of style "
    141             f"file, URL of style file, or library style name (library "
    142             f"styles are listed in `style.available`)") from err
    143 filtered = {}
    144 for k in style:  # don't trigger RcParams.__getitem__('backend')

OSError: 'seaborn-whitegrid' is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)

To use recent matplotlib versions, we need modify the logic in _visualization.plot, make it compatible with recent versions of matplotlib.

@csrgxtu
Copy link
Author

csrgxtu commented Aug 1, 2024

after modify, test it, and got following:
img_v3_02db_c674c7cd-3360-4316-8572-bb20cf52277g

@csrgxtu
Copy link
Author

csrgxtu commented Aug 1, 2024

@tailaiw @roycoding plz help review this PR.

@am2222
Copy link

am2222 commented Oct 18, 2024

Any chance this gets approved?

@tbenhamou
Copy link

Can you guys merge it please?

earthgecko added a commit to earthgecko/adtk that referenced this pull request Jun 12, 2025
IssueID #5631: Replace deprecated seaborn-whitegrid

- Replace deprecated seaborn-whitegrid with seaborn-v0_8-whitegrid to address
  arundo#152
  arundo#156

Modified:
src/adtk/visualization/_visualization.py
earthgecko added a commit to earthgecko/adtk that referenced this pull request Jun 12, 2025
IssueID #5631: Replace deprecated seaborn-whitegrid

- Replace deprecated seaborn-whitegrid with seaborn-v0_8-whitegrid to address
  arundo#152
  arundo#156

Modified:
src/adtk/visualization/_visualization.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants