1

Right now, my polar plots look like this:

enter image description here

But I need them to look like this:

enter image description here

Is there a way to specify a major and minor unit for both the angular and radial axes in pyplot? I would like to use matplotlib but since installing freetype is a huge hassle and I will have to get IT involved, I would like to see if I can do it with pyplotfirst.

Thanks

RBuntu
  • 907
  • 10
  • 22

1 Answers1

1

I took this example and added some lines from this question. Hope this fits your needs:

import numpy as np
import matplotlib.pyplot as plt


r = np.arange(0, 2, 0.01)
theta = 2 * np.pi * r

ax = plt.subplot(111, projection='polar')
ax.plot(theta, r)
ax.set_rmax(2)
ax.set_rticks([0.5, 1, 1.5, 2])  # less radial ticks
ax.set_rlabel_position(-22.5)  # get radial labels away from plotted line
ax.grid(True)

ax.set_title("A line plot on a polar axis", va='bottom')

# angle axis
major_ticks = np.linspace(0, 2*np.pi, 36, endpoint=False)
minor_ticks = np.linspace(0, 2*np.pi, 360, endpoint=False)

ax.set_xticks(major_ticks, minor=False)
ax.set_xticks(minor_ticks, minor=True)

# ls for linestyle, lw for linewidth
ax.xaxis.grid(True, ls='-', lw=2, which='major')
ax.xaxis.grid(True, which='minor')


# radial axis
# angle axis
major_ticks = np.linspace(0, 2, 4, endpoint=False)
minor_ticks = np.linspace(0, 2, 40, endpoint=False)

ax.set_yticks(major_ticks, minor=False)
ax.set_yticks(minor_ticks, minor=True)

# ls for linestyle, lw for linewidth
ax.yaxis.grid(True, ls='-', lw=2, which='major')
ax.yaxis.grid(True, which='minor')

plt.show()

This gives the following picture [You might need to adjust some details ;-) ]: output

Community
  • 1
  • 1
Michael H.
  • 3,323
  • 2
  • 23
  • 31