How can I stop scatter chart from autoscaling when data set changes


I’m wondering if there’s a way to get Plotly.js to stop autoscaling the chart when the data changes.

For example, I have a scatter chart that looks like this:


I select the points at the bottom like this:


I hit delete to remove those point, but rather than show an empty region where the selection was, it seems to adjust the scale so that the remaining points fill the space:


I would like to stop that behavior if possible. Does anyone know how I can do that?

Hi @gibran.shah, not sure if this helps, but you could try setting connectgaps=false

Sorry AIMPED, I think I wasn’t clear enough. What I mean is the gap between the remaining points and the bottom of the chart is reduced after deleting the points:

big gap

small gap

This is happening because the chart is scaling. Since the points near the bottom don’t exist anymore, there is no point in leaving a gap, so it scales (zooms in) a bit to fill the entire chart. But several of our testers found that very confusing. It looked to them as if the data was changing so we want to prevent it (having said this, another option might be to get a smooth animation from the “before” state to the “after” state; that way, the user can see exactly what’s going on–i.e. it’s scaling or “zooming in”).

In this case you could fix the yaxis range.

Thanks AIMPED. I tried setting yaxis.fixedrange before but realized I was doing something wrong. I did it the right way this time and it works. However, it seems now that zooming in/out no longer works (not surprisingly). We only want the chart to not scale when we delete data points, but we would still like it to scale when we zoom in/out with the mouse scroll wheel. I don’t suppose this is possible, is it?