2017-09-15 49 views
0
return { 
    height: 210, 
    title: title, 
    autosize: true, 
    width: '100%', 
    font: { 
    size: 10, 
    family: "Roboto" 
    }, 
    showlegend: false, 
    margin: { 
    l: 40, 
    r: 10, 
    b: 35, 
    t: 22, 
    pad: 0 
    }, 
    xaxis: { 
    nticks: 6, 
    title: "Score", 
    linecolor: '#cccccc', 
    zerolinewidth: 0, 
    zerolinecolor: '#fff' 
    }, 
    yaxis: { 
    title: "Number of students", 
    linecolor: '#cccccc', 
    zerolinewidth: 0, 
    zerolinecolor: '#eeeeee', 
    range: [0, numStudents] 
    }, 
    bargap: 0.5 
}; 

这包括半音以及1.5等。我使用plotly.js,这是我所看到的:如何删除非整数的plotly.js图的轴线?

enter image description here

+0

尝试设置'{y轴:{dtick:1}}' –

+0

你能做出一个答案,我会接受吗? – Shamoon

回答

1

您可以强制Plotly使用定义轴之间的距离在你的情况设置你的轴,即该layout选项dtick蜱这将是

{yaxis: {dtick: 1}} 

为没有layout设置VS固定dtick的例子见下文。

var trace1 = { 
 
    x: ['A', 'B', 'C'], 
 
    y: [1, 3, 2], 
 
    mode: 'markers', 
 
    type: 'bar' 
 
}; 
 

 
Plotly.newPlot('myPlot1', [trace1], {yaxis: {dtick: 1}}); 
 
Plotly.newPlot('myPlot2', [trace1]);
<script src="https://cdn.plot.ly/plotly-latest.min.js"> 
 
</script> 
 
<div id = "myPlot1" ></div> 
 
<div id = "myPlot2" ></div>