Iโm trying to have the y and x axis for a scatterplot have the same scale when the graph is first displayed. However, upon zooming, I would like for the user to not be constrained to only fixed ratio zooms. Currently the scaleanchor attribute is great for the initial display but zooms are also fixed. What workarounds are there around this?
Hi @nicolascage,
Youโre right that that scaleratio property is designed to constrain the zoom level as well. You should be able to set up the initial proportions using:
-
fig.layout.widthandfig.layout.heightto set the overall figure width/height - The
l,r,t,b, properties offig.layout.marginto set the spacing between the outer edge of the plotting area and the outside of the figure. -
rangeproperty offig.layout.xaxisandfig.layout.yaxisto set the axis range extents.
So the aspect ratio of your plotting area (in screen coordinates) will be
(width - margin.l - margin.r)/(height - margin.t - margin.b)
Then you can set the ratio between the xaxis.range and yaxis.range to be some factor times this aspect ratio:
factor*(width - margin.l - margin.r)/(height - margin.t - margin.b)=
(xaxis.range[1] - xaxis.range[0])/(yaxis.range[1] - yaxis.range[0])
Hope that helps get you started!
-Jon
Hi @jmmease. Thanks for the detailed and quick response as usual. I look forward to trying this out, and will let you know how it turns out!
1 Like