plotly / plotly/plotly.js

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

オープン
#8,005 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P2 size: 1
主要言語
JavaScript
スター
18.3k
フォーク
2k
平均マージ
2日 12時間
マージ済み PR(30日)
28

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、負の z 値を使用し、histfunc を avg、min、または max に設定した histogram2dcontour trace の、提供されている CodePen 再現例を実行します。histogram2dcontour のレンダリングパスを追跡し、3 つすべての関数で、負の bin の輪郭塗りつぶしが対応するラベルおよび colorscale と一致することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript
領域
data-visualization
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
65/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。