Change the radius tick label positions in a polar Matplotlib plot

Python

Matplotlib

Polar

Change radius tick positions

Luc B.

Python

Matplotlib

Polar Plot

Tick labels in Matplotlib polar plots often need to be adjusted so they aren't obstructed by lines. Matplotlib allows users to rotate radius tick labels to any polar angle, meaning labels can be precisely positioned to avoid data.

Code Example

Polar tick label positions can only be changed using Matplotlib's object oriented interface. Use the Axes.set_rlabel_position() function.

import matplotlib.pyplot as plt
import numpy as np

theta = np.linspace(0, np.pi, 100)
r = np.sin(theta)

ax = plt.axes(projection="polar")
ax.plot(theta, r)

# Rotate tick label positions here
ax.set_rlabel_position(-45)

plt.show()

png