plotly / plotly/plotly.py

px.density_contour() ignores color labels for negative histfunc results

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

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

bug P3
主要言語
Python
スター
18.8k
フォーク
2.8k
平均マージ
16時間 26分
マージ済み PR(30日)
21

説明

Consider the following example:

import plotly.express as px
import pandas as pd
import numpy as np
import plotly


np.random.seed(0)

n_samples = 1000
df = pd.DataFrame({
    'x': np.random.randint(low=1, high=5, size=n_samples),
    'y': np.random.randint(low=1, high=4, size=n_samples),
    'z': np.random.normal(loc=-40, scale=20, size=n_samples),
})

df['z'] = df['z'] * df['x']

# uncomment to make some values above 0
# df['z'] = df['z'] + 80

# uncomment to make all values above 0
# df['z'] = df['z'].abs()

fig = px.density_contour(df, x='x', y='y', z='z', histfunc='avg', height=800, width=1200, title=f'Plotly version: {plotly.__version__}')
fig.update_traces(contours_coloring="fill", contours_showlabels=True)
fig.show()

It calculates average of mostly negative values, which results in the following plot:
image

Color bar has correct color range, but all data points use same color - yellow, which is not particularly useful. Similar situation happens when only part of data is negative (uncomment first commented line in the example):

image
Left (positive) section looks fine, while right (negative) is colored with only one color.

There are workarounds, that involve changing of input data, but this makes plot reading much harder.

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

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

はじめの一歩

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

調査の方向性

まず、負の値および混在した histfunc の結果を使用して、提供されている px.density_contour() の例を実行し、次に density_contour のエントリーポイントと、等高線の色付けがそれらの値をどのように処理するかを調べます。負の結果と混在した結果が 1 色に縮退せず、完全なカラーレンジを使用し、既存の正のケースも引き続き正しく動作すれば完了です。

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

評価

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

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

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