How to update existing plot's axis range using slider without re-calculation

use read_csv to read a big file and do some calculation. After calculation, I created a heatmap and some line plots.

Now I’d like to change heatmap’s colorbar range and line plot’s y axis range as well using slider.

I don’t want to read csv and do calculation again to generate the plots using new axis range. How do I just update existing plot’s axis range?

I am thinking to create a callback, get the figure from the graph, then use fig.update_yaxis(), then return figure to same graph.

This way both input and output has same graph’s figure which is not allowed. any suggestion or other way to do it?


 Output("line-graph", "figure"),
 Input("line-graph", "figure"),
 Input("lineplot-range-slider-items", "value"),

def update_fig_axis_range(fig,axis_range_slider):

    fig.update_xaxes(title_text='name',title_font = {"size": 20},tickfont=dict(size=16),

    return fig
               marks={int(x) if x % 1 == 0 else x :{'label':'{:.0f}'.format(x),'style':{'color':'blue'}} 
                     for x in np.arange(min_y,max_y,step_y)},
               tooltip={"placement": "bottom", "always_visible": True},

anyone here help? Thanks