positions of the ticks and ticklabels

Hi,

How do I get the coordinates of the ticks and their labels in a coordinate system that I can feed to figtext or text?

I want to display some additional text near one of the ticklabels on the x axis. Although I could get the coordinates for figtext using trial and error, but is there a correct way of doing this (using transformations?) so that my text does not move relative to the tick labels.

Thanks!

Abhi

Hi Abhi,

I added an example program which illustrates my idea using transformation of
axes-coord. to screen-coord. and from screen-coord. to fig-coord.

point_screen = ax.transAxes.transform_point(point_ax)
point_fig = fig.transFigure.inverted().transform_point(point_screen)

I don't know if this is the best approach, but (at least) this works for me.

Kind regards,
Matthias

positions_of_the_ticks_and_ticklabels.py (1.46 KB)

···

On Monday 07 December 2009 21:38:17 Abhimanyu Lad wrote:

Hi,

How do I get the coordinates of the ticks and their labels in a coordinate
system that I can feed to figtext or text?
I want to display some additional text near one of the ticklabels on the x
axis. Although I could get the coordinates for figtext using trial and
error, but is there a correct way of doing this (using transformations?) so
that my text does not move relative to the tick labels.

Thanks!
Abhi

I added an example program which illustrates my idea using transformation of

axes-coord. to screen-coord. and from screen-coord. to fig-coord.

point_screen = ax.transAxes.transform_point(point_ax)

point_fig = fig.transFigure.inverted().transform_point(point_screen)

Actually, I wanted my text to not move relative to one of the x-axis labels.

I found the solution with some tinkering. Basically, I needed to grab the transformation of the labels.

tx = ax.get_xticklabels()[0]

text(1.5, 0.0, “some text”, transform=tx.get_transform())

To also get a constant offset:

text(1.5, 0.0, “some text”, transform=tx.get_transform() + ScaledTransformation(-.1,-.1, fig.dpi_scale_trans))

Thanks,

Abhi

···

On Tue, Dec 8, 2009 at 3:27 AM, Matthias Michler <MatthiasMichler@…361…> wrote:

On Monday 07 December 2009 21:38:17 Abhimanyu Lad wrote:

Hi,

How do I get the coordinates of the ticks and their labels in a coordinate

system that I can feed to figtext or text?

I want to display some additional text near one of the ticklabels on the x

axis. Although I could get the coordinates for figtext using trial and

error, but is there a correct way of doing this (using transformations?) so

that my text does not move relative to the tick labels.

Thanks!

Abhi