plotly / plotly/plotly.js

UI revision does not work while specifying projection type

未关闭
#6,840 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug P2
主要语言
JavaScript
星标
18.3k
派生
2k
平均合并
2 天 12 小时
30 天内合并 PR
28

描述

i’ve been unable to make uirevision to work while using the orthographic projection on 3D scatter plot using graph object.
here’s a simplified example (i'm not as familiar with JS , therefore the example is in python.) :

import dash
from dash import dcc, html
from dash.dependencies import Input, Output
import plotly.graph_objs as go
import pandas as pd
from numpy.random import randn
# Sample data
data = {
    'sepal_width': [3.5, 3.0, 3.2, 3.1, 3.6],
    'sepal_length': [5.1, 4.9, 4.7, 4.6, 5.0],
    'petal_length': [1.4, 1.4, 1.3, 1.5, 1.4],
}
data2 = {
    'sepal_width': [3.5, 3.0, 3.2, 3.1, 3.6]*3,
    'sepal_length': [5.1, 4.9, 4.7, 4.6, 5.0]*2,
    'petal_length': [1.4, 1.4, 1.3, 1.5, 1.4]*1,
}
df = pd.DataFrame(data)

# Initial Figure
scatter_figure = go.Figure()
scatter_figure.layout.uirevision = True
scatter_figure.layout.scene.camera.projection.type = 'orthographic'
# Add 3D Scatter Plot Trace
scatter_figure.add_trace(
    go.Scatter3d(
        x=df['sepal_width'],
        y=df['sepal_length'],
        z=df['petal_length'],
        mode='markers',
        marker=dict(
            size=12,
            opacity=0.7,
        ),
        scene='scene',
    )
)

# Dash app
app = dash.Dash(__name__)

# Layout
app.layout = html.Div([
    dcc.Graph(
        id='scatter-plot',
        figure=scatter_figure,
    ),
    dcc.Checklist(
        id='toggle-checklist',
        options=[
            {'label': 'Toggle Plot', 'value': 'toggle'}
        ],
        value=['toggle'],
    ),
])

# Callback to toggle plot visibility
@app.callback(
    Output('scatter-plot', 'figure'),
    [Input('toggle-checklist', 'value')]
)
def toggle_plot(value):
    if 'toggle' in value:
        # If 'toggle' is in the value, show the plot
        return scatter_figure
    else:
        df = data2
        scatter_figure.add_trace(
            go.Scatter3d(
                x=df['sepal_width'],
                y=df['sepal_length'],
                z=df['petal_length'],
                mode='markers',
                marker=dict(
                    size=12,
                    opacity=0.7,
                ),
                scene='scene',
            )
        )
        return scatter_figure

# Run the app
if __name__ == '__main__':
    app.run_server(debug=True,port = 8078)

every time I'm toggling the check box the view completely reversed to its original position, and only when I'm specifying projection to be orthographic , works perfectly on perspective.

I'd really appeiciate you looking into this :)
Happy New Year and thanks in advance.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从提供的 Dash/Python 复现开始,重点关注当 scene.camera.projection.type 设置为正交投影时 3D 散点图的 uirevision 行为。比较在正交投影和透视投影下切换 checklist;完成的标准是切换 plot 时相机视图保持在当前位置。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript
领域
data-visualization
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。