plotly / plotly/plotly.js

[BUG]: `histogram2dcontour` uses wrong fill colors for negative values

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

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

bug P2 size: 1
Ngôn ngữ chính
JavaScript
Star
18.3k
Fork
2k
Merge trung bình
2 ngày 12 giờ
Pull request đã merge (30 ngày)
28

Mô tả

First reported in plotly.py: https://github.com/plotly/plotly.py/issues/3799

histogram2dcontour traces use incorrect fill colors when bin values are negative.

Negative bin values can occur when histfunc is set to 'avg', 'min', or 'max', and the input z array contains negative values.

When some bin values are negative, all negative bin values are filled with the same color as 0 on the colorscale, while the outermost fill level is filled with the same color as the lowest number on the colorscale.

Example

Codepen reproduction: https://codepen.io/emilykl-code/pen/PwpPjMb

Code:

Show code
const x = [1, 2, 3, 4, 1, 2, 3, 4];
const y = [1, 1, 1, 1, 2, 2, 2, 2];
// The bug is triggered when histfunc is 'avg', 'min', or 'max',
// and some z-values are negative such that some resulting bin values
// end up negative
// This example uses all-negative z values to show the most extreme
// case, but not all z-values need to be negative to trigger the bug
const z = [-10, -50, -100, -150, -10, -50, -100, -150];

Plotly.newPlot('div1', [{
  type: 'histogram2dcontour',
  x: x,
  y: y,
  z: z,
  histfunc: 'avg',  // or 'min' or 'max'
  contours: {
    coloring: 'fill',
    showlabels: true,
  },
}],
 {
   title: {
     text: 'histogram2d contour plot: wrong fill colors!',
     subtitle: {
       text: 'Compare contour labels on plot to colorscale'
     }
 }
});

Screenshot:
Image

Expected behavior

Contour fills should match fill colors indicated by colorscale

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.

Hướng nghiên cứu

Bắt đầu bằng cách chạy bản tái hiện CodePen được cung cấp cho một trace histogram2dcontour sử dụng các giá trị z âm và có histfunc được đặt thành avg, min hoặc max. Theo dõi đường dẫn kết xuất histogram2dcontour và xác minh rằng phần tô đường đồng mức của các bin âm khớp với nhãn tương ứng và colorscale trên cả ba hàm.

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

Đánh giá

Công nghệ
javascript
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
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
65/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.