gpt4 book ai didi

javascript - 是否可以在 plot.ly 3D 散点图上手动设置比例和刻度?

转载 作者:行者123 更新时间:2023-11-30 16:01:17 25 4
gpt4 key购买 nike

我有一个基本的 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>

代码演示:https://rocket-league-replays.github.io/3d-hitmaps/

最佳答案

我不太熟悉 javascript plotly api,这个答案是用 python 编写的。希望它对您的情况也有帮助。

如果我正确理解你的问题,你想为轴设置 tickmode,并且根据你选择的模式,你还想设置 nticks; tick0 和 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 position tick0 and a tick step dtick ("linear" is the default value if tick0 and dtick are provided). If "array", the placement of the ticks is set via tickvals and the tick text is ticktext. ("array" is the default value if tickvals is provided).

关于javascript - 是否可以在 plot.ly 3D 散点图上手动设置比例和刻度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37689268/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com