Top/Right Tick Labels

Can someone point out how to simply label the ticks on the top and right of a plot? twinx() and twiny() are not necessary because I don’t need independent scales and the mpl_toolkits.axes_grid.parasite_axes module is a bit too limiting for my purposes.

(Part of my confusion stems from the fact that I can access the Tick instances on the Axis but when I call Tick.set_label2(“New Label”) the label does not get drawn. Perhaps I am being daft.)

Thanks in advance.

-Andrew

http://matplotlib.sourceforge.net/api/axis_api.html#matplotlib.axis.Tick

You need to set label2On attribute as True.

I think there is no convenient function that do this, other than
manually iterate over the ticks.

Regards,

-JJ

···

On Thu, Jan 21, 2010 at 1:16 PM, Andrew Kelly <ndrukelly@...287...> wrote:

(Part of my confusion stems from the fact that I can access the Tick
instances on the Axis but when I call Tick.set_label2("New Label") the label
does not get drawn. Perhaps I am being daft.)

Turning label2On = true turned on the labels as directed. However, the function label2.set_text(“New Tick Label”) does not update the actual text. I can set_size(), etc and it works, but set_text() does not update. Any ideas why?

-Andrew

···

On Thu, Jan 21, 2010 at 10:32 AM, Jae-Joon Lee <lee.j.joon@…287…> wrote:

On Thu, Jan 21, 2010 at 1:16 PM, Andrew Kelly <ndrukelly@…287…> wrote:

(Part of my confusion stems from the fact that I can access the Tick

instances on the Axis but when I call Tick.set_label2(“New Label”) the label

does not get drawn. Perhaps I am being daft.)

http://matplotlib.sourceforge.net/api/axis_api.html#matplotlib.axis.Tick

You need to set label2On attribute as True.

I think there is no convenient function that do this, other than

manually iterate over the ticks.

Regards,

-JJ

You should not call set_text directly, instead you need to call
Axis.set_ticklabels.
If you want the top (right) ticks have different ticklabels than the
bottom (left) ticks, that is not possible.
You need to make another axes by calling twin*.

-JJ

···

On Thu, Jan 21, 2010 at 2:31 PM, Andrew Kelly <ndrukelly@...287...> wrote:

Turning label2On = true turned on the labels as directed. However, the
function label2.set_text("New Tick Label") does not update the
actual text. I can set_size(), etc and it works, but set_text() does not
update. Any ideas why?

So twiny() is up and running with a FixedLocator and Formatter for the ticks on the upper xAxis but am now unable to rotate these tick labels. Is there a special method to set the rotation, etc with FixedLocators?

···

On Thu, Jan 21, 2010 at 3:09 PM, Jae-Joon Lee <lee.j.joon@…2015…87…> wrote:

On Thu, Jan 21, 2010 at 2:31 PM, Andrew Kelly <ndrukelly@…287…> wrote:

Turning label2On = true turned on the labels as directed. However, the

function label2.set_text(“New Tick Label”) does not update the

actual text. I can set_size(), etc and it works, but set_text() does not

update. Any ideas why?

You should not call set_text directly, instead you need to call

Axis.set_ticklabels.

If you want the top (right) ticks have different ticklabels than the

bottom (left) ticks, that is not possible.

You need to make another axes by calling twin*.

-JJ