Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Layout Templates and matplotlib figures

Đang mở
#207 16 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
jupyter-notebook, matplotlib
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện ví dụ Layout Templates trong issue trên Jupyter Notebook và JupyterLab, sau đó đọc phần thảo luận trong #117 và công việc hiện có trong #174. Kết quả mong muốn vẫn chưa được xác định; hãy làm rõ một cách tiếp cận cho phép các figure của matplotlib lấp đầy widget layout trong khi vẫn giữ nguyên tỷ lệ khung hình của chúng, sau đó xác định cách cần kiểm chứng hành vi này.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

see #117 (issue) and #174 (PR) for some discussion on the topic.

@martinRenou I have been playing with using Layout Templates to stack figures in fun ways. Unfortunately, since matplotlib is currently responsible for the figure size, I end up with situations such as the following, where the figures are all cut off a bit. This is particularly noticable in jupyter notebook since the screen width is reduced.

In the following example, I stack a 4x4 of buttons and then a 4x4 of figures. The buttons stretch nicely, but the figures do not.

%matplotlib widget
import matplotlib.pyplot as plt
from ipywidgets import TwoByTwoLayout
from ipywidgets.widgets import Button, Layout

# Buttons
def button(name):
    return Button(description = name, layout=Layout(height='auto', width='auto'))

a,b,c,d =  button("1"), button("2"), button("3"), button("4"),
layout_2x2 = TwoByTwoLayout(top_left=a, 
                            top_right=b,
                            bottom_left=c,
                            bottom_right=d)
display(layout_2x2)

# Figures
figs = []
plt.ioff()
for i in range(4):
    fig, ax = plt.subplots()
    ax.imshow([[1,2], [3,4]])
    figs.append(fig.canvas)

a,b,c,d = figs

layout_2x2 = TwoByTwoLayout(top_left=a, 
                            top_right=b,
                            bottom_left=c,
                            bottom_right=d)
display(layout_2x2)

In jupyter lab the problem is less so, but still unfortunate that figures basically ignore the flexbox layout the widgets are designed with. I would set the size with matplotlib, but since I don't know the size of the viewport the user is using, it's likely that the size I choose will be too small or too large depending on the user.

I don't have a concrete solution at hand, but I'm wondering if we can come up with some logic that preserves aspect ratio but otherwise fills a widget to its fullest extent?

Ngôn ngữ chính
Jupyter Notebook
Star
1.7k
Fork
234
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

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của matplotlib/ipympl

Tất cả issue của matplotlib/ipympl

Issue tương tự

Thêm issue về Web Dev

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.