Matplotlib – Seaborn-whitegrid ist kein gültiger PaketstilPython

Python-Programme
Guest
 Matplotlib – Seaborn-whitegrid ist kein gültiger Paketstil

Post by Guest »

Ich verwende ADTK zur Anomalieerkennung und matplotlib zur Visualisierung, erhalte jedoch beim Versuch, mein Programm auszuführen, Fehlermeldungen. Dies ist mein Code und ich verwende Python3

Code: Select all

import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as mdates

from adtk.data import validate_series
from adtk.visualization import plot
from adtk.detector import PersistAD

data = pd.read_csv('SQL_bytes_sent_ferdig.csv', index_col="time", parse_dates=True)
# Convert the index to a DatetimeIndex explicitly if it's not already
data.index = pd.to_datetime(data.index, utc=True)

# Add 1 hour to the index
data.index = data.index + pd.Timedelta(hours=1)
data_valid = validate_series(data)

persist_ad = PersistAD(c=3.0, side='positive')
anomalies = persist_ad.fit_detect(data_valid)

plot(data_valid, anomaly=anomalies, ts_linewidth=1, ts_markersize=3, anomaly_markersize=3, anomaly_color='red', anomaly_tag="marker");
Beim Ausführen wird der folgende Fehler angezeigt:

Code: Select all

/home/ubuntu/ad/sql_ad.py:1: DeprecationWarning:
Pyarrow will become a required dependency of pandas in the next major release of pandas (pandas 3.0),
(to allow more performant data types, such as the Arrow string type, and better interoperability with other libraries)
but was not found to be installed on your system.
If this would cause problems for you,
please provide us feedback at https://github.com/pandas-dev/pandas/issues/54466

import pandas as pd
/home/ubuntu/.local/lib/python3.10/site-packages/adtk/detector/_detector_1d.py:270: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value 'nan' has dtype incompatible with bool, please explicitly cast to a compatible dtype first.
predicted[s.isna()] = np.nan
/home/ubuntu/.local/lib/python3.10/site-packages/adtk/detector/_detector_1d.py:141: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value 'nan' has dtype incompatible with bool, please explicitly cast to a compatible dtype first.
predicted[s.isna()] = np.nan
/home/ubuntu/.local/lib/python3.10/site-packages/adtk/aggregator/_aggregator.py:211: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value 'nan' has dtype incompatible with bool, please explicitly cast to a compatible dtype first.
predicted[predicted & lists.isna().any(axis=1)] = float("nan")
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.10/site-packages/matplotlib/style/core.py", line 137, in use
style = _rc_params_in_file(style)
File "/home/ubuntu/.local/lib/python3.10/site-packages/matplotlib/__init__.py", line 866, in _rc_params_in_file
with _open_file_or_url(fname) as fd:
File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
return next(self.gen)
File "/home/ubuntu/.local/lib/python3.10/site-packages/matplotlib/__init__.py", line 843, in _open_file_or_url
with open(fname, encoding='utf-8') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'seaborn-whitegrid'

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

Traceback (most recent call last):
File "/home/ubuntu/ad/sql_ad.py", line 22, in 
plot(data_valid, anomaly=anomalies, ts_linewidth=1, ts_markersize=3, anomaly_markersize=3, anomaly_color='red', anomaly_tag="marker");
File "/home/ubuntu/.local/lib/python3.10/site-packages/adtk/visualization/_visualization.py", line 201, in plot
plt.style.use("seaborn-whitegrid")
File "/home/ubuntu/.local/lib/python3.10/site-packages/matplotlib/style/core.py", line 139, in use
raise OSError(
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`)
Ich habe mir andere Beiträge mit ähnlichen Problemen angesehen und versucht anzugeben, welchen Stil ich in meinem Code verwenden soll. Dabei habe ich die folgenden Stile:

Code: Select all

import matplotlib.pyplot as plt
# plt.style.use(['science', 'notebook'])
print(plt.style.available)
Gibt:

Code: Select all

['Solarize_Light2', '_classic_test_patch', '_mpl-gallery', '_mpl-gallery-nogrid', 'bmh', 'classic', 'dark_background', 'fast', 'fivethirtyeight', 'ggplot', 'grayscale', 'seaborn-v0_8', 'seaborn-v0_8-bright', 'seaborn-v0_8-colorblind', 'seaborn-v0_8-dark', 'seaborn-v0_8-dark-palette', 'seaborn-v0_8-darkgrid', 'seaborn-v0_8-deep', 'seaborn-v0_8-muted', 'seaborn-v0_8-notebook', 'seaborn-v0_8-paper', 'seaborn-v0_8-pastel', 'seaborn-v0_8-poster', 'seaborn-v0_8-talk', 'seaborn-v0_8-ticks', 'seaborn-v0_8-white', 'seaborn-v0_8-whitegrid', 'tableau-colorblind10']
Aber keine davon ändert den Fehler. Wenn ich es in Jupytor Notebook ausführe, funktioniert es und ich muss nicht einmal angeben, welches Diagramm verwendet werden soll. Ich habe versucht, Seaborn mit Pip zu installieren, aber es funktioniert immer noch nichts.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post