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.width
andfig.layout.height
to set the overall figure width/height - The
l
,r
,t
,b
, properties offig.layout.margin
to set the spacing between the outer edge of the plotting area and the outside of the figure. -
range
property offig.layout.xaxis
andfig.layout.yaxis
to 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