plotly / plotly/plotly.py

wrong customdata shape in go.Surface

未關閉
#3,308 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

bug P3
主要語言
Python
星號
18.8k
分支
2.8k
平均合併
16 小時 26 分鐘
30 天內合併 PR
21

描述

It appears that I have found a bug when using customdata with go.Surface. In the following example, I have discretized two directions with a different number of points. The tooltip is going to visualize information coming from x, y, z coordinates as well as customdata.

import numpy as np
import plotly.graph_objects as go
import plotly.express as px

x = np.linspace(-3, 3, 50)
y = np.linspace(-5, 5, 100)
x, y = np.meshgrid(x, y)
z = np.sqrt(x + 1j * y)
angle = np.angle(z)
z = np.absolute(z)

fig = go.Figure()
skw = dict(
    showscale=True,
    colorbar=dict(
        title="Argument",
        titleside="right",
        tickvals = [
            -np.pi,
            -np.pi / 2,
            0,
            np.pi / 2,
            np.pi,
        ],
        ticktext = [
            "-π",
            "-π / 2",
            "0",
            "π / 2",
            "π",
        ]
    ),
    cmin = -np.pi,
    cmax = np.pi,
    colorscale=px.colors.sequential.Rainbow,
    surfacecolor=angle,
    customdata=angle,
    hovertemplate="x: %{x}<br />y: %{y}<br />Abs: %{z}<br />Arg: %{customdata}",
)
fig.add_trace(
    go.Surface(x=x, y=y, z=z, **skw)
)
fig

This is the output picture. You can see a discontinuity at y=0. However, if you move the mouse on the right of the discontinuity, customdata won't show up.

On the other hand, if I'm going to use customdata=angle.T, than the tooltip will show the correct data.

I believe that customdata should have the same shape as the x, y, z coordinates.

newplot(8)

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從提供的 Python 重現開始,使用 go.Surface 和 NumPy 陣列,重點關注 customdata 如何用於 x、y 和 z 的非方形形狀。比較 customdata=angle 與 customdata=angle.T 的行為;當 tooltip 在不連續點的兩側都能正確顯示 customdata 時,該 issue 即完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
numpy, python
領域
data-visualization
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。