AttributeError: module 'matplotlib' has no attribute 'pyplot'
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- jupyter, matplotlib, python
- Lĩnh vực
- backend, data-visualization
Hướng nghiên cứu
Bắt đầu tại matplotlib_inline/backend_inline.py dòng 100, nơi matplotlib.pyplot.close('all') gây ra AttributeError được báo cáo. Tái hiện lỗi với cách sử dụng notebook đã cho và so sánh với việc import rõ ràng matplotlib.pyplot; hoàn tất khi việc dọn dẹp inline không còn thất bại khi backend được sử dụng như mô tả.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Jupyter Notebook
- Star
- 31
- Fork
- 39
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ipython/matplotlib-inline
-
Support animations Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
ipython/matplotlib-inline#61 ·
-
sdist is missing tests Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
ipython/matplotlib-inline#59 ·
-
Publish changelog Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
ipython/matplotlib-inline#57 · 1 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
ipython/matplotlib-inline#54 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 48/100
ipython/matplotlib-inline#44 · 1 bình luận ·
Tất cả issue của ipython/matplotlib-inline
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
speaches-ai/speaches#678 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
[BUG] ECR GetAuthorizationToken returns a proxyEndpoint for the default region, not the request's Đang mởbug ecr
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
conda-forge/spacy-feedstock#177 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100