我有一个基本的plot.ly 3D散点图,其中包含在三维空间中指定的各种路径。经过三天的阅读文档后,我仍然没有找到定义轴的刻度间隔的方法。它似乎是根据我的数据自动生成它们,这是我不想要的。实际上,我需要三个轴的比例为 1:1:1,这可能吗?
<style>html, body { height: 100%; }</style>
<div id="myDiv" style="width: 100%; height: 100%"></div>
<!-- Latest compiled and minified plotly.js JavaScript -->
<script type="text/javascript" src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script>
var data = [
{
x: [-886, -719],
y: [-4785, -5192],
z: [527, 501],
type: 'scatter3d'
},
{
x: [-1782, -92],
y: [1740, -5172],
z: [18, 252],
type: 'scatter3d'
},
{
x: [3844, -450],
y: [35, -5185],
z: [20, 219],
type: 'scatter3d'
},
{
x: [2770, 761],
y: [2360, -5122],
z: [246, 96],
type: 'scatter3d'
},
{
x: [3800, 546],
y: [-3419, -5215],
z: [57, 311],
type: 'scatter3d'
},
{
x: [-340, 775],
y: [-3893, -5189],
z: [573, 135],
type: 'scatter3d'
},
{
x: [-3141, -41],
y: [3677, -5205],
z: [18, 383],
type: 'scatter3d'
},
{
x: [19, -546],
y: [261, -5181],
z: [74, 93],
type: 'scatter3d'
},
{
x: [3, 789],
y: [394, -5165],
z: [112, 421],
type: 'scatter3d'
}
];
var layout = {
// height: 700,
// width: 700,
xaxis: {
range: [-5000, 5000]
},
yaxis: {
range: [-5000, 5000]
}
};
Plotly.newPlot('myDiv', data, layout);
</script>
最佳答案
我不太熟悉javascript的plotly api,这个答案是用python写的。希望它对您的情况也有帮助。
如果我正确理解你的问题,你想设置轴的刻度模式,并且根据你选择的模式,你还想设置刻度;刻度0和dticks;或刻度值。
以下内容摘自:https://plot.ly/python/reference/#layout-scene-xaxis-tickmode一个难以有效搜索但非常有用的页面。该页面的 javascript 版本是:https://plot.ly/javascript/reference/#layout-scene-xaxis-tickmode
tickmode (enumerated: "auto" | "linear" | "array" ) Sets the tick mode for this axis. If "auto", the number of ticks is set via
nticks
. If "linear", the placement of the ticks is determined by a starting positiontick0
and a tick stepdtick
("linear" is the default value iftick0
anddtick
are provided). If "array", the placement of the ticks is set viatickvals
and the tick text isticktext
. ("array" is the default value iftickvals
is provided).
关于javascript - 是否可以在plot.ly 3D散点图上手动设置比例和刻度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37689268/