Python Program to Plot Rose Curves Using Numpy & Matplotlib


This Python example plots polar curve to produce Rose like curve using numpy and matplotlib library.


In mathematics, rose curve has general form r = a sin (n*θ) or r = a cos (n*θ). Here a is constant and n is an integer.

Rose Curve With Even Petals

Python Source Code


# Python program to Plot Rose curve with even number of petals
import numpy as np
from matplotlib import pyplot as plt

theta = np.linspace(0, 2*np.pi, 1000)

r = 3* np.sin(8 * theta)

plt.polar(theta, r, 'r')

plt.show()

Output

Python Rose Curve Even Petals
Figure: Python Rose Curve (Even Petals)

Rose Curve With Odd Petals

Python Source Code


# Python program to Plot Rose curve with even number of petals
import numpy as np
from matplotlib import pyplot as plt

theta = np.linspace(0, 2*np.pi, 1000)

r = 3* np.cos(5 * theta)

plt.polar(theta, r, 'r')

plt.show()

Output

Python Rose Curve Odd Petals
Figure: Python Rose Curve (Odd Petals)