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

标签 javascript plotly

我有一个基本的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写的。希望它对您的情况也有帮助。

如果我正确理解你的问题,你想设置轴的刻度模式,并且根据你选择的模式,你还想设置刻度;刻度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 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/

相关文章:

javascript - Vue中使用事件修饰符.prevent实现无重定向提交表单

javascript - 无效数据, block 必须是缓冲区的字符串,而不是对象

javascript - 是否可以在plotly.js箱形图上叠加标记?

python - 将多个 Y 轴与 Plotly 中的一个值对齐

javascript - 如何改变javascript格式占位符的颜色?

javascript - 自上而下滚动后导航栏可见点自动调整

javascript - 如何为基于 Web 的应用程序启用直接打印功能?

python - 每次将点添加到 CSV 文件时更新图表 - python

python - 使用按钮在plotly python中过滤不同的数据

javascript - 如何删除 plotly.js x 轴刻度标签/按钮?