plotly / plotly/plotly.py

Can not use transparency in px.imshow

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

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

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

説明

I am using plotly 4.12.0.
The px.imshow function has this example in the docs:

import plotly.express as px
import numpy as np
img_rgb = np.array([[[255, 0, 0], [0, 255, 0], [0, 0, 255]],
                    [[0, 255, 0], [0, 0, 255], [255, 0, 0]]
                   ], dtype=np.uint8)
fig = px.imshow(img_rgb)
fig.show()

I have tried to add transparency to the plot with the following code:

import plotly.express as px
import numpy as np
img_rgb = np.array([[[255, 0, 0, .5], [0, 255, 0, .5], [0, 0, 255, .5]],
                    [[0, 255, 0, .5], [0, 0, 255, .5], [255, 0, 0, .5]]
                   ])
fig = px.imshow(img_rgb)
fig.show()

As suggested by the docs, passing a (M, N, 4), array would include transparency, but this resulted in an empty figure:
image

Using go.Image directly worked:

fig = go.Figure()
fig.add_traces(go.Image(z=img_rgb, colormodel='rgba'))

image

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

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

はじめの一歩

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

調査の方向性

(M, N, 4) 配列を使用して、報告された px.imshow の例で空の図を再現し、その後、colormodel='rgba' を使用する動作する go.Image の例と比較します。px.imshow が 4 チャネル画像の入力をどのように処理するかを追跡します。px.imshow がドキュメントどおりに透明度付きで画像をレンダリングすれば完了です。

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

評価

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

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

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