AttributeError: module 'matplotlib' has no attribute 'pyplot'
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- jupyter, matplotlib, python
- Ambito
- backend, data-visualization
Direzione di ricerca
Inizia da matplotlib_inline/backend_inline.py alla riga 100, dove matplotlib.pyplot.close('all') genera l'AttributeError segnalato. Riproduci il problema con l'utilizzo mostrato del notebook e confrontalo con un'importazione esplicita di matplotlib.pyplot; il lavoro è completato quando la pulizia inline non fallisce più usando il backend come descritto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
While attempting to create a piano roll with librosa and matplotlib, like this:
def plot_piano_roll(pm, start_pitch, end_pitch, fs=100):
# Use librosa's specshow function for displaying the piano roll
librosa.display.specshow(pm.get_piano_roll(fs)[start_pitch:end_pitch],
hop_length=1, sr=fs, x_axis='time', y_axis='cqt_note',
fmin=pretty_midi.note_number_to_hz(start_pitch))
plt.figure(figsize=(8, 4))
plot_piano_roll(pm, 56, 70)
I encounter this error:
AttributeError Traceback (most recent call last)
File ~/anaconda3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:100, in show(close, block)
97 # only call close('all') if any to close
98 # close triggers gc.collect, which can be slow
99 if close and Gcf.get_all_fig_managers():
--> 100 matplotlib.pyplot.close('all')
File ~/anaconda3/lib/python3.9/site-packages/matplotlib/_api/__init__.py:226, in caching_module_getattr.<locals>.__getattr__(name)
224 if name in props:
225 return props[name].__get__(instance)
--> 226 raise AttributeError(
227 f"module {cls.__module__!r} has no attribute {name!r}")
AttributeError: module 'matplotlib' has no attribute 'pyplot'
The error seems to be fixed if I explicitly declare import matplotlib.pyplot as plt at the start of the file and then use that to call it like this: plt.close('all'). If that alone is satisfactory, I would request to do a PR.
- Lingua principale
- Jupyter Notebook
- Stelle
- 31
- Fork
- 39
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ipython/matplotlib-inline
-
Support animations Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
ipython/matplotlib-inline#61 ·
-
sdist is missing tests Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
ipython/matplotlib-inline#59 ·
-
Publish changelog Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
ipython/matplotlib-inline#57 · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
ipython/matplotlib-inline#54 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
ipython/matplotlib-inline#44 · 1 commento ·
Tutte le issue di ipython/matplotlib-inline
Issue simili
-
bug customer-eng Durable Agents Inngest status: needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
-
integration: elevenlabs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
home-assistant/core#182944 · 1 commento ·
-
ai-observability bug team/ai-observability
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
vicharanashala/fln#563 ·