Scaleanchor/scaleratio not working

Hi,

I’m trying to set a graph I have to be square using scaleanchor/scaleratio as such:

          fig = go.Figure()
          fig.update_layout(
              plot_bgcolor = 'white',
          )
          fig.update_xaxes(
              showline = True,
              linecolor = 'black',
              mirror = True,
              range = [xmin, xmax],
              title_text = 'relative x position (degrees)',
          )
          fig.update_yaxes(
              showline = True,
              linecolor = 'black',
              mirror = True,
              range = [ymin, ymax],
              title_text = 'relative y position (degrees)',
              scaleanchor = 'x',
              scaleratio = 1,
          )

In this case xmin = ymin and xmax = ymax. The graph, though, still seems to come out as a rectangle:


I’m using plotly version 5.15.0.
Thanks for any help.

The use of scaleanchor does not necessarily create a square plot. It fixes the scaling between the axes, I think.

In this example, I chose a different figure height/width on purpose:

Not sure if I understand teh problem, though.

Hi,
I’ve looked into this problem since this reply and am realizing that I was mistaken what the issue was and it is independent of scaleanchor/scaleratio, and using gridlines does show that scaleanchor/ratio are working properly. The problem is that my graph’s axes ranges are not actually staying within the specified ranges, though I feel I should create a separate question for this.
Still using the code above (plus additional code to display gridlines), here’s what the graph looks like when adding a second trace indicated by red dots where the graph ranges should be constrained:
image

        fig.add_trace(
                go.Scatter(
                    mode = 'markers',
                    x = [xmin, xmin, xmax, xmax],
                    y = [ymin, ymax, ymin, ymax],
                    marker = dict(
                        color = 'red'
                    )
                )
            )

It is clear from here that scaleanchor/ratio were working as intended. Sorry for the confusion.