Aspect ratio plotly

Is there a way to force the aspect ratio of a plotly 2D plot to be square?
If yes, what is the exact syntax?

In Plotly 2.0 you can set the width and height to create a square plot:

Sorry if my question was not clear. What I want is fixed aspect ratio so that I get the same scale on both axes.

In that case you will want to set a custom range for your axes:

See more about axes properties in Plotly 2.0 here: http://help.plot.ly/axes/

Hi @priis,

If you’re using the APIs there are now examples of fixed ratio in R, Python, and JS.

I know this is an old question, but just for clarification @prils, does @bcd’s answer address your question?

The API key’s that @bcd recommends, scaleanchor and scaleratio, controls the relative spacing/length of the x and y axis, so that 1 unit on the x and y axis correspond to the same physical length.

This is great, but I’ve been wanting to be able to control the relative lengths of x and y axis, so that regardless of the relative scales of the x and y axis, the resulting plot area’s shape is always preserved.

Setting the plot width and height doesn’t really cut it since that needs to account for chart elements like axis titles and what not.

Any ideas community?

three reasons why you should buy plotly pro: support open source, get great support, host your plots and dashboards online