Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add methods to control theta position of r-ticklabels on polar plots #2549

Merged
merged 1 commit into from Nov 23, 2013

Conversation

joferkington
Copy link
Contributor

Currently, there's no easy way to control the position of the radius ticklabels on polar plots. It can be done with angle kwarg to ax.set_rgrids, but that requires manually setting the tick positions.

This pull request adds methods to get/set the angular position of the r-ticklabels without forcing the axis to use a FixedLocator (as set_rgrids would do).

As an example, if we want to change the position of the radius ticklabels on a polar plot from the default:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='polar')
plt.show()

figure_1

To a different position:

figure_1

You currently have to use private methods:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='polar')

position = 202.5
ax._r_label_position._t = (position, 0)
ax._r_label_position.invalidate()

plt.show()

Or manually set the r tick locations as well as the label locations using set_rgrids, which forces you to used a fixed tick locator:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='polar')

position = 202.5
ax.set_rgrids(np.arange(0.2, 1.2, 0.2), angle=position)

plt.show()

This pull request allows one to do:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='polar', rlabel_position=202.5)
plt.show()

Or use an axes method:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='polar')
ax.set_rlabel_position(202.5)
plt.show()

@mdboom
Copy link
Member

mdboom commented Oct 30, 2013

Looks like a good PR all around.

As for radians vs. degrees, since this has mostly to do with a position for display and of primary importance to humans, I think I prefer it in degrees (i.e. the way it is), but I hear you able the inconsistency with theta_offset.

What do others think?

@efiring
Copy link
Member

efiring commented Oct 30, 2013

Definitely stick with degrees. The fact that theta_offset is presently in radians is a design flaw.

tacaswell added a commit that referenced this pull request Nov 23, 2013
Add methods to control theta position of r-ticklabels on polar plots
@tacaswell tacaswell merged commit 432d9d8 into matplotlib:master Nov 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants