Is it possible to control the text of the polar grid
> labels? I would like to have 8 grid lines in theta, but
> label only 4 of them. I also want to set my own labels,
> such as "NE", "NW", "SW" and "SE".
Gee, you give them a feature and the next thing you know they're gonna
want to customize it.....
> I would like to turn off the labels along r completely or
> replace them with my own set of labels.
> The comments in polar_demo.py indicate that the properties
> of the gridlines and labels can be accessed directly from
> the polar axes. How can I find out what keywords can be
> set for each of the attributes: thetagridlines, rgridlines,
> thatagridlabels and rgridlabels?
I added two customization functions to matplotlib.matlab: rgrids and
thetagrids. These can be used to set the radial and theta grid
locations and labels. Here is an example script
from matplotlib.matlab import *
ax = axes([0.1, 0.1, 0.8, 0.8], polar=True, axisbg='#d5de9c')
r = arange(0,1,0.001)
theta = 2*2*pi*r
polar(theta, r, color='#ee8d18', lw=3)
rline, rtext = rgrids((0.25, 0.5, 0.75), labels=('a', 'b', 'c'))
#rgrids() # for no labels
angles = arange(0, 360,45)
labels = ('', 'NE', '', 'NW', '', 'SW','', 'SE', '')
thetalines, thetatext = thetagrids( angles, labels )
set(thetatext, color='r', fontsize=14)
See the help for the new functions rgrids and thetagrids for more
detailed info. This supersedes the instructions in polar_demo.
Note that both functions return lines, labels. These are lists of
Line2D instances and Text instances. You can call
set(lines, linewidth=2.0, color='g')
set(text, fontsize=20, color='r')
set operates on a list of objects or a single object, and for each key
value pair looks for a method based on the key (with 'set_' prefixed)
and tries to call
So the properties you can set on the list of lines are all the methods
that start with set_ at
and for the text instances are all the methods that start with set_ at
I'm attaching the two modified files. Drop these in
site-packages/matplotlib and you should be good to go.
Let me know how it goes!
matlab.py (37.2 KB)
axes.py (96 KB)