2016-06-07 39 views
1

我有一個基本的plot.ly具有三維指定的各種路徑的三維散點圖。在閱讀了三天的文檔之後,我仍然沒有找到一種方法來定義我的軸的滴答間隔。它似乎是基於我的數據自動生成它們,我不想要這些數據。實際上,我需要我的三個軸以1:1:1的比例,這是可能的嗎?是否可以手動設置plot.ly三維散點圖上的刻度和刻度?

<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/

回答

2

我使用JavaScript API plotly不太熟悉,這個答案是在考慮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(列舉: 「自動」 | 「線性」 | 「陣列」) 設置此軸上的刻度模式。如果「自動」,則通過nticks設置滴答數。如果是「線性」,則標記的位置由起始位置tick0和標記步驟dtick確定(如果提供tick0dtick,則「線性」是默認值)。如果是「陣列」,則通過tickvals設置滴答的位置,並且滴答文本爲ticktext。 (如果提供了tickvals,則「數組」是默認值)。

0

同樣,這是爲python,但在場景選項中,有一種方法可以使用xaxis(或yaxis或zaxis)中的範圍(列表)選項來設置x,y或z軸的範圍,下面是一個示例代碼。

scene = dict(xaxis=dict(gridcolor='rgb(0, 0, 0)', 
            zerolinecolor='rgb(0, 0, 0)', 
            showbackground=False, 
            range = (minX,maxX)), 
         yaxis=dict(gridcolor='rgb(0, 0, 0)', 
            zerolinecolor='rgb(0, 0, 0)', 
            showbackground=False, 
            range = (minY, maxY)), 
         zaxis=dict(gridcolor='rgb(0, 0, 0)', 
            zerolinecolor='rgb(0, 0, 0)', 
            showbackground=False, 
            range = (minZ, maxZ))) 
fig['layout'].update(scene) 

這裏是文檔:https://plot.ly/python/reference/#layout-xaxis-range和Java https://plot.ly/javascript/reference/#layout-xaxis-range