Reputation: 3734
In plotly the axis range can be set manually with yaxis: {range: [0,10]}
e.g. https://codepen.io/plotly/pen/YXbwyo.
However, how can I set only the lower limit manually to 0
, while the upper limit should autoscale?
Upvotes: 1
Views: 1048
Reputation: 19565
You can set the parameters rangemode:'tozero'
and autorange:true
in the layout.
I modified the traces in your codepen to not include the points where x=0 and the lower limit of the range is indeed 0 while the upper limit autoscales to the largest x- and y-values.
var trace1 = {
x: [1, 2, 3, 4, 5, 6, 7, 8],
y: [7, 6, 5, 4, 3, 2, 1, 0],
type: 'scatter'
};
var trace2 = {
x: [1, 2, 3, 4, 5, 6, 7, 8],
y: [1, 2, 3, 4, 5, 6, 7, 8],
type: 'scatter'
};
var data = [trace1, trace2];
var layout = {
xaxis: {rangemode: 'tozero',
autorange: true},
yaxis: {rangemode: 'tozero',
autorange: true},
};
Plotly.newPlot('myDiv', data, layout, {showSendToCloud: true});
Upvotes: 1