dkogan / dkogan/gnuplotlib

Multiplot fails if it is the first plot in the script

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

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

Ngôn ngữ chính
Python
Star
274
Fork
17
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

When a script has a multiplotas it's very first plot, the plot produced it's a regular plot, the second plot overwrites the first one withouth any error indication:

Let's use this small example:

import numpy as np
import gnuplotlib as gp
th = np.linspace(0, 2*np.pi, 100)
x1 = np.cos(th)
y1 = np.sin(th)
x2 = 2*np.cos(th)
y2 = 3*np.sin(th)

gp.plot(
    ((
        x1,
        y1,
        dict(
            legend = "Circle",
            _with = "linespoints dt 4 pt 4",
        )),
     dict(
         title="Circle",
         xlabel="X",
         ylabel="Y",
     )),
    ((
        x2,
        y2,
        dict(
            legend = "Ellipse",
            _with = "linespoints dt 4 pt 4",
        )),
     dict(title="Ellipse",
         xlabel="X",
         ylabel="Y",
     )),
    _wait=True,
    square=True,
    multiplot="layout 2,1"
)

This produces the following output:

multiplot_1

As we see, the Ellipse plot has overwritten the Circle plot, totally ignoring the multiplot argument. No warnings, no errors. Just silently ignores the option.

However, if we add a regular plot before the multiplot:

import numpy as np
import gnuplotlib as gp
th = np.linspace(0, 2*np.pi, 100)
x1 = np.cos(th)
y1 = np.sin(th)
x2 = 2*np.cos(th)
y2 = 3*np.sin(th)
# Dummy plot so multiplot doesn't fail
gp.plot(
    np.sin(th),
    np.cos(th),
    _wait=True,
)

gp.plot(
    ((
        x1,
        y1,
        dict(
            legend = "Circle",
            _with = "linespoints dt 4 pt 4",
        )),
     dict(
         title="Circle",
         xlabel="X",
         ylabel="Y",
     )),
    ((
        x2,
        y2,
        dict(
            legend = "Ellipse",
            _with = "linespoints dt 4 pt 4",
        )),
     dict(title="Ellipse",
         xlabel="X",
         ylabel="Y",
     )),
    _wait=True,
    square=True,
    multiplot="layout 2,1"
)

We get the desired output

multiplot_2

One curious effect is that this only works if _wait=True is provided in the Dummy Plot

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

  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.

Hướng nghiên cứu

Bắt đầu bằng cách chạy hai bản tái hiện bằng Python từ issue và lần theo cách dự án xử lý plot và multiplot. So sánh trường hợp plot đầu tiên với trường hợp được đặt trước bởi một plot giả và _wait=True. Hoàn thành khi một script có plot đầu tiên sử dụng multiplot="layout 2,1" render cả hai plot mà không cần plot giả hoặc âm thầm ghi đè plot đầu tiên.

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

Đánh giá

Công nghệ
numpy, python
Lĩnh vực
data-visualization
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
42/100

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.