Can you remove the hover-coordinate-lines in Plotly Python Scatter3d

半腔热情 提交于 2020-01-14 12:56:26

问题


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:


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>


来源:https://stackoverflow.com/questions/46348625/can-you-remove-the-hover-coordinate-lines-in-plotly-python-scatter3d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!