+ 3
Difficulty in Plotting circles in Python using Mathplotlib and NumPy.
I have tried plotting a circle in Python but get a distorted curve where there is a circle in the 1st and 4th quadrants but a straight line joining the highest point on the 1st quadrant to the lowest point in the 4th quadrant and I'm unable to get a proper circle. The code is given as: center_1_x = -2 radius_1 = 6 x_values = np.linspace(center_1_x - radius_1, center_1_x + radius_1, 100, endpoint=True) y_values = np.sqrt(abs((radius_1 ** 2) - (x_values - center_1_x) ** 2)) * np.sign(x_values - center_1_x) plt.plot(x_values, y_values, color='blue')
3 Respostas
+ 4
Maybe this way will help you:
https://code.sololearn.com/cNzbb27XUyes/?ref=app
+ 2
Well by making two values of y_values like y_values_p and y_values_n, I have been able to solve the problem by not considering np.sign statement
+ 1
or you can force a square shaped plot
plt.gca().set_aspect('equal')
https://code.sololearn.com/cbCT6dsuXY56/?ref=app