Get_container_width to keep plot aspect ratio

I’m looking to do a sort of animation within a plot (moving a square or circle around on the figure), but it is important that the aspect ratio of the plot doesn’t change, even with changing browser width, otherwise the square looks like a rectangle and the circle looks like an ellipse. The command to make the plot the same size as the container width works well in auto-scaling with width, but I’d like to be able to access the container width property so I can scale the chart to the right height to keep the aspect ratio correct. Is there currently a way to do this?

A matplotlib chart would work out of the box, but that’s because it streams out an image. I’d like to use a little less bandwidth and provide more interactivity.