Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing labels in matplotlib polar plot

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: enter image description here

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

like image 217
DotPi Avatar asked Apr 18 '13 14:04

DotPi


People also ask

How do you change the label on a plot in Python?

Use the xlabel() method in matplotlib to add a label to the plot's x-axis. In the above example, we import matplotlib. pyplot package and define the data coordinates for plotting. After that, the plot() method is used to draw a line between y and x.


1 Answers

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

like image 112
Francesco Montesano Avatar answered Sep 25 '22 13:09

Francesco Montesano