CairoMakie: how to set appropriate animation margins?

I created the below animation of the elastic pendulum using CairoMakie and this code.

My only qualm with it is the plot margins; they are too wide. I would like the Cartesian plane shown to span most of the animation window, not like 20% of it. How do I address this issue? I have tried to address this by setting the x and y limits and resolution, but these don’t seem to actually address this issue.

    resize_to_layout!(fig)

try remove this?

Sure, but I added it to fix this issue. Removing it leads to this animation. I don’t think there’s any difference.

oh, aspect = DataAspect(), I guess this is the issue, try to remove it or set it to something else (like 1.0).

I mean it really depends on what you want, because your axies size are quite different

You can try autolimitaspect = 1 instead which will try to increase the limits to reach that aspect ratio. If you get a stack overflow because of layout cycles with that then fix the tick spacing with tight_ticklabel_spacing!(ax)