Trouble Setting Y-Axis Range Dynamically in Plotly

Hi everyone,

I’m encountering an issue with dynamically setting the Y-axis range in a Plotly plot. I’m using jQuery to fetch the min and max Y values from input fields and trying to apply these to the Y-axis of a Plotly chart. The code compiles without errors, and the values seem correct when logged, but the plot does not reflect the updated Y-axis range. Here’s the relevant part of my code:

// Initial layout configuration
let layout = {
    hovermode: 'x unified',
    spikedistance: '-1',
    xaxis: {
        title: 'Time (UTC)',
        spikemode: 'across',
        showspikes: true,
        spikesnap: 'cursor',                
    yaxis: {
        title: {
            text: yaxistitles['y'],
            standoff: 20,
        domain: [0, (nr_of_actual_plots > 1 ? (1 / nr_of_actual_plots) - 0.03 : 1)]
    height: 1200

// Checking if the checkbox is checked and setting the range
if ($('#use_y_axis_limits_0').is(':checked')) {
    var minY = parseFloat($('#min_y_0').val());
    var maxY = parseFloat($('#max_y_0').val());

    if (!isNaN(minY) && !isNaN(maxY)) {
        layout['yaxis']['range'] = [minY, maxY];

    console.log('type of range:', typeof layout['yaxis']['range']);

console.log('layout:', layout);
Plotly.newPlot('plot', data, layout, config);

Despite this setup, the plot does not adjust to the new Y-axis range specified. The console logs the expected range values correctly, and there are no JavaScript errors thrown. I’ve confirmed the type of the range values are what Plotly expects (array of numbers).

Has anyone encountered this issue before, or does anyone have suggestions on what might be going wrong? Any advice or insights would be greatly appreciated!

Thank you in advance for your help!