Search code examples
plotlyplotly.js

plotly.js: How to determine the start and end of axes range


How to get this:

enter image description here

Instead of this:

enter image description here


Solution

  • Use layout.xaxis.range and layout.yaxis.range:

    const layout = {
        xaxis: {
            range: [0, 100], // https://plotly.com/javascript/reference/#layout-xaxis-range
        },
        yaxis: {
            range: [0, 100],
        }
    }
    
    Plotly.newPlot( 'myDiv', data, layout, config)