Plotly, same scale for x and y axis

farhawa picture farhawa · Jun 24, 2015 · Viewed 17.6k times · Source

I am using plotly for python and I can't set x and y axis so they could have the same scale:

Here is my layout:

layout = Layout(
    xaxis=XAxis(
        range=[-150, 150],
        showgrid=True,
        zeroline=True,
        showline=True,
        gridcolor='#bdbdbd',
        gridwidth=2,
        zerolinecolor='#969696',
        zerolinewidth=4,
        linecolor='#636363',
        linewidth=6
    ),
    yaxis=YAxis(
        range=[-150,150],
        showgrid=True,
        zeroline=True,
        showline=True,
        gridcolor='#bdbdbd',
        gridwidth=2,
        zerolinecolor='#969696',
        zerolinewidth=4,
        linecolor='#636363',
        linewidth=6
    )
)

And then I get something like this!

enter image description here

Why is the scale is different for x and y? that will affect my visualization.

How can I get a grid with a square cells?

Answer

Max picture Max · Oct 23, 2017

Finally, this feature is implemented.

layout = go.Layout(yaxis=dict(scaleanchor="x", scaleratio=1))

See example here https://plot.ly/python/axes/#fixed-ratio-axes.