Fail to plot an ellipse in polar coordinates in Matplotlib

Viewed 21

Why does my polar plot fails, the two plots should be completely identical! I cannot for my life see what goes wrong. There is no advanced concepts anywhere, just a simple plot, still it does not work.

# importing libraries
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt

# Creating equally spaced data points in range 0 to 2*pi
theta = np.linspace(0, 2 * np.pi, 100)

# Setting radiuses 
Rx = 10
Ry = 4

# Generating (x,y) and r
x = Rx * np.cos(theta) 
y = Ry * np.sin(theta)
r = np.sqrt(x**2 + y**2)

# Plotting
plt.plot(x, y, color='blue')
plt.axis('equal')
plt.title('Ellipse')
plt.show()

Ellipse

# Plotting polar
plt.polar(theta, r, color='red')
plt.title('Why??')
plt.show()

enter image description here

0 Answers
Related