【问题标题】:Interactive zmax for plotly heatmap?用于情节热图的交互式 zmax?
【发布时间】:2021-12-07 11:47:03
【问题描述】:

是否可以使绘图热图的 zmax 设置交互?我正在使用 Python 在 Jupyter Notebook 中生成热图,如果可以通过在颜色栏、滑块或类似内容中输入新数字直接在绘图上更改 zmax,那就太好了。

【问题讨论】:

    标签: jupyter-notebook plotly plotly-python


    【解决方案1】:
    • 直接输入需要破折号
    • 仅使用 plotly,您可以获得预定义值的菜单
    import plotly.graph_objects as go
    
    fig = go.Figure(data=go.Heatmap(z=[[1, 20, 30], [20, 1, 60], [30, 60, 1]]))
    fig.update_layout(
        updatemenus=[
            {
                "buttons": [
                    {"label": str(v), "method": "restyle", "args": [{"zmin": 0, "zmax": v}]}
                    for v in range(10, 60, 10)
                ]
            }
        ]
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-22
      • 2019-01-18
      • 1970-01-01
      • 2012-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多