Changing labels in matplotlib polar plot

2020-04-05 08:30发布

问题:

I am using matplotlib to create polar plots to represent Rose Diagrams. Right now the plot is getting created perfectly. I want to replace the angles being displayed on the axis with direction names: N for 0 degrees, W for 90 degrees, S for 180 degrees and E for 270 degrees.

The current rose diagram looks like the following:

Note: I have tried with windrose but this output is more appropriate for my purpose. Hence a good way of assigning custom labels to the axes will be very helpful.

The python version I am using is 2.6 with matplotlib version 1.2.0

回答1:

Assuming that you have an axes object ax you can do simply do something like this

ax.set_xticklabels(['N', '', 'W', '', 'S', '', 'E', ''])

or get some inspiration by this old example