How to plot sine curve on polar axes using Matplotlib?

To plot a sine curve on polar axes using Matplotlib, we need to create a polar coordinate system and plot angular data. Polar plots are useful for representing periodic data and circular patterns.

Steps to Create a Polar Sine Plot

  • Set the figure size and adjust the padding between and around the subplots
  • Create a new figure using figure() method
  • Add polar axes using add_subplot(projection='polar')
  • Generate angular data points (theta) and radius values using numpy
  • Plot the data using plot() method on polar axes
  • Display the figure using show() method

Example

import numpy as np
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

fig = plt.figure()
ax = fig.add_subplot(projection='polar')

# Create angular data (theta) and radius data
theta = np.linspace(0, 4*np.pi, 100)
radius = np.sin(theta)

ax.plot(theta, radius, color='red', lw=3)
ax.set_title('Sine Curve on Polar Axes', pad=20)

plt.show()

Enhanced Polar Sine Plot

Here's a more detailed example showing multiple sine curves with different frequencies ?

import numpy as np
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = [8, 8]
plt.rcParams["figure.autolayout"] = True

fig = plt.figure()
ax = fig.add_subplot(projection='polar')

# Generate theta values
theta = np.linspace(0, 4*np.pi, 200)

# Plot multiple sine curves with different frequencies
r1 = np.sin(theta)
r2 = np.sin(2*theta)
r3 = np.sin(3*theta)

ax.plot(theta, r1, 'r-', linewidth=2, label='sin(?)')
ax.plot(theta, r2, 'g-', linewidth=2, label='sin(2?)')
ax.plot(theta, r3, 'b-', linewidth=2, label='sin(3?)')

ax.set_title('Multiple Sine Curves on Polar Axes', pad=20)
ax.legend(loc='upper left', bbox_to_anchor=(0.1, 1.1))

plt.show()

Key Points

  • Theta (?): Represents the angle in radians on polar axes
  • Radius (r): Represents the distance from the origin
  • projection='polar': Creates polar coordinate system instead of Cartesian
  • Negative radius values are plotted in the opposite direction
90° 180° 270° Polar Coordinate System r = sin(?)

Conclusion

Polar plots are ideal for visualizing periodic functions like sine curves. Use projection='polar' to create polar axes, where theta represents angles and radius represents distance from origin.

Updated on: 2026-03-25T23:22:27+05:30

877 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements