Can you remove the hover-coordinate-lines in Plotl

2019-06-24 12:49发布

When using Plotly Scatter3D , the default mouse hover-over effect displays a kind of coordinate crosshairs. Is there a way to remove this effect and just show the tooltip?

1条回答
ゆ 、 Hurt°
2楼-- · 2019-06-24 13:27

The hover effect causing the lines to show up on the axis are called spikes in Plotly. You can disable them via layout = {'scene': {'xaxis': {'showspikes': False}}}.

Interactive Javascript example:

Plotly.d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/3d-scatter.csv', function(err, rows) {
  function unpack(rows, key) {
    return rows.map(function(row) {
      return row[key];
    });
  }
  var trace = {
    x: unpack(rows, 'x2'),
    y: unpack(rows, 'y2'),
    z: unpack(rows, 'z2'),
    mode: 'markers',
    marker: {
      color: 'rgb(127, 127, 127)',
      size: 12,
      symbol: 'circle',
      line: {
        color: 'rgb(204, 204, 204)',
        width: 1
      },
      opacity: 0.9
    },
    type: 'scatter3d'
  };
  var data = [trace];
  var layout = {
    scene: {
      xaxis: {
        showspikes: false
      },
      yaxis: {
        showspikes: false
      },
      zaxis: {
        showspikes: false
      }
    }
  };
  Plotly.newPlot('myDiv', data, layout);
});
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<div id="myDiv" style="width:100%;height:100%"></div>

查看更多
登录 后发表回答