隐藏用于Web的Plotly上的颜色栏

问题描述 投票:0回答:1

代码:

<script>
            var z1 = [[1, 2, 1, 10, 3], [1, 4, 3, 1, 2], [8, 4, 5, 1, 2]];
            var x1 = [2, 4, 6, 8, 10];
            var y1 = [3, 6, 9];

                {% if x1 and y1 and z1 %}
              z1 = {{z1|tojson}};
              x1 = {{x1|tojson}};
              y1 = {{y1|tojson}};
                {% endif %}

        var data_z1 = { z: z1, x: x1, y: y1, type: 'surface', colorscale: 'Lava'/*, colorbar: {showscale: false}*/};
        var layout = {
              plot_bgcolor: "#dddddd",
              paper_bgcolor:"#dddddd",
              scene: { camera: { eye: { x: 1.8, y: 1.8, z: 1.5 } } },
              width: window.innerWidth / 100 * 19.2,
              height: window.innerWidth / 100 * 19.2,
              margin: {
                l: 0,
                r: 0,
                b: 0,
                t: window.innerWidth / 100 * 1.94
              }
            };

            Plotly.newPlot('myFunction', [data_z1], layout);

    </script>

我正在使用在线Plotly绘图仪,希望从视图中隐藏颜色条,尝试按照提到的here进行操作,但无济于事。

javascript html web plotly
1个回答
0
投票

showlegend变量中为layout尝试以下操作...showlegend: false,

https://plotly.com/javascript/legend/#hiding-the-legend

var layout = {
  plot_bgcolor: "#dddddd",
  paper_bgcolor:"#dddddd",
  scene: { camera: { eye: { x: 1.8, y: 1.8, z: 1.5 } } },
  width: window.innerWidth / 100 * 19.2,
  height: window.innerWidth / 100 * 19.2,
  showlegend: false,
  margin: {
    l: 0,
    r: 0,
    b: 0,
    t: window.innerWidth / 100 * 1.94
  }
};
© www.soinside.com 2019 - 2024. All rights reserved.