使用 Plotly Scatter3D 时,默认的鼠标悬停效果会显示一种坐标十字准线。有没有办法去除这种效果并只显示工具提示?
最佳答案
使线条显示在轴上的悬停效果在 Plotly 中称为 spikes
。您可以通过 layout = {'scene': {'xaxis': {'showspikes': False}}}
禁用它们。
交互式 Javascript 示例:
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>
关于python-3.x - 您可以删除 Plotly Python Scatter3d 中的悬停坐标线吗,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46348625/