I'm trying to create some circles with Bezier curves for my numerical computation class, but I keep ending up with ellipses instead. I want to achieve a more circular shape without relying heavily on AI. Here's my code that attempts to create circles using Bezier curves by plotting the top and bottom halves separately. I'd appreciate any tips or improvements!
1 Answer
First off, it looks like one issue is your aspect ratio. Your plot's axes are uneven: the bottom axis spans from 5 to 7 (2 units wide), while the side axis stretches from 18 to 22 (4 units high). This makes any circle you've plotted appear as an ellipse because the scaling is off. Make sure to set the aspect ratio to equal, like this:`plt.gca().set_aspect('equal', adjustable='box')`. This should help your circles look more circular! Also, consider adjusting your x and y limits using `plt.xlim()` and `plt.ylim()` to ensure you're viewing the right range of values.
Thanks for the tip! I implemented `set_aspect` and it did fix the look. But I’m curious, why aren’t the axes equal by default? It seems odd that it could mess up the plotting!
Good question! The default behavior of Matplotlib is to make the plot fit the figure window, so unless you manually set the aspect ratio, it might not maintain equal scaling. Glad it helped though!