Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Axis equal option?

In some situations it is important that the distance for a given range in data is identical along the x and y axes (or z for 3D plots). In Matlab it is possible to use the “axis equal” constraint in such cases but I haven’t yet been able to find equivalent functionality in Plotly.

I have been successful at getting the correct aspect ratio for the axes and ranges for the case depicted below left where the plot legend is wholly within the axis boundaries and the plot width and height are identical (the two magenta “measuring sticks” on the outer axis bounds have identical lengths). Where I have failed, however, is the case below right where the plot is configured identically except that the legend now is to the right of the x-axis upper bound. Here what I would like to have happen is that the y-axis of the plot would shrink such that its upper bound (35) would move down to the position of the horizontal magenta line. In this way the data / axis aspect ratio would be identical to that of the x-axis. I know that this effect could be accomplished by reducing the plot height but I see no a priori way to know what value to use to preserve the data / aspect ratio given that I have no information on the width of the legend.

Thanks very much in advance to anyone who can help me get the behavior that I seek!

I don’t believe this is possible, but thank you for the excellent write up.
I would suggest creating an issue in Plotly.js if one does not already exist for this:

Thanks for the suggestion. Here’s a link to the issue that I created:
https://github.com/plotly/plotly.js/issues/1384