controlling padding between axis and ticklabels in polar plots

Hello,

I have a question concerning the label positions of x- or y-ticks. My
problem is that I want to make a polar plot with ticklabels. To
generate such a plot you can use the following simple example script.

# #################################################
import numpy as np
import matplotlib.pyplot as plt

r = np.linspace(0, 10, 100)
t = np.linspace(0, 4*np.pi, 100)

fig = plt.figure(1)
fig.clf()
ax = fig.add_subplot(1,1,1, polar=True)
ax.plot(t, r, lw=2)

plt.draw()
plt.show()
# ##################################################

When generating a polarplot with this script one realizes that the
r-ticklabels (y-ticklabels) end up on the gridlines. This looks looks
kind of ugly especially for the last ticklabel ("10") which breaks the
solid line at the outer plot boundary. So I would like to move the
ticklabels a little bit to the right.

My question is: Is there a simple trick to change the default
ticklabelpad between the axis and the ticklabels or do I have to do
this manually by changing the position of every single ticklabel?

About a short answer I would be very glad.

With kind regards,

Daniel

There seems no obvious way to change the padding.
You may use *set_rgrids* method which takes rpad parameter but you
need to specify the tick locations also.

Here is a simple function taken from set_rgrids method, that only
change the padding.

def update_rpads(ax, rpad):
    angle = ax._r_label1_position.to_values()[4]
    rmax = ax.get_rmax()
    ax._r_label1_position.clear().translate(angle, rpad * rmax)
    ax._r_label2_position.clear().translate(angle, -rpad * rmax)

update_rpads(ax, rpad=0.05)

Regards,

-JJ

ยทยทยท

On Tue, Apr 13, 2010 at 12:08 PM, Daniel Platz <mail.to.daniel.platz@...982...> wrote:

Hello,

I have a question concerning the label positions of x- or y-ticks. My
problem is that I want to make a polar plot with ticklabels. To
generate such a plot you can use the following simple example script.

# #################################################
import numpy as np
import matplotlib.pyplot as plt

r = np.linspace(0, 10, 100)
t = np.linspace(0, 4*np.pi, 100)

fig = plt.figure(1)
fig.clf()
ax = fig.add_subplot(1,1,1, polar=True)
ax.plot(t, r, lw=2)

plt.draw()
plt.show()
# ##################################################

When generating a polarplot with this script one realizes that the
r-ticklabels (y-ticklabels) end up on the gridlines. This looks looks
kind of ugly especially for the last ticklabel ("10") which breaks the
solid line at the outer plot boundary. So I would like to move the
ticklabels a little bit to the right.

My question is: Is there a simple trick to change the default
ticklabelpad between the axis and the ticklabels or do I have to do
this manually by changing the position of every single ticklabel?

About a short answer I would be very glad.

With kind regards,

Daniel

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options