|
From: Anthony M. F. <Ant...@co...> - 2007-07-13 16:36:52
|
For the archives (and further proof that programming done during the
witching hour between 4pm and 5pm should be avoided at all costs):
The solution is easy.
for tick in axes.yaxis.get_major_ticks():
tick.set_pad(-25)
tick.label2.set_horizontalalignment('right')
A>
=20
> -----Original Message-----
> From: Anthony M. Floyd=20
> Sent: July 12, 2007 4:37 PM
> To: mat...@li...
> Subject: [Matplotlib-users] Properly aligned tick labels on the inside
>=20
> Hi All,
>=20
> I'm trying to plot tick labels on the inside (ie data side)=20
> of a typical x-y plot. My setup is Python 2.5.1, matplotlib=20
> 0.90.0 on WinXP.
>=20
> I've been able to accomplish this by adjusting the padding of=20
> the individual ticks, but it doesn't quite accomplish what I want.
>=20
> For example, imagine a typical x-y plot, except that the tick=20
> labels are on the right-hand side (by setting=20
> axes.yaxis.tick_right()). Adjusting the padding of the ticks=20
> by doing:
>=20
> for tick in axes.yaxis.get_major_ticks():
> tick.set_pad(-25)
>=20
> I'm able to get the numbers to appear about where I want. =20
> The problem is that these numbers are left aligned. So, it=20
> works fine for small numbers, but for large numbers, or when=20
> my tick formatter switches over to using scientific notation=20
> the numbers will overlap the axis. If my labels are on the=20
> inside of the right-hand side, I want them to be=20
> right-aligned and grow left towards the centre of the plot.
>=20
> I thought about doing it by setting tick_left() and then=20
> using a (large) computed pad, but then the tick lines are on=20
> the wrong side.
>=20
> So, my question is: can I get right-aligned tick labels on=20
> the right-side of a plot? How?
>=20
> I suspect I can do this by using=20
> axis.set_offset_position('...'), but I've been unable to get=20
> that to do anything in my tests using pylab.
>=20
> I can post code if it'll be helpful.
>=20
> Thanks,
> Anthony.
>=20
> --
> Anthony Floyd, PhD
> Convergent Manufacturing Technologies Inc.
> 6190 Agronomy Rd, Suite 403
> Vancouver BC V6T 1Z3
> CANADA
>=20
> Email: Ant...@co... | Tel: 604-822-9682
> WWW: http://www.convergent.ca | Fax: 604-822-9659 =20
>=20
> CMT is hiring: See http://www.convergent.ca for details
>=20
>=20
>=20
> --------------------------------------------------------------
> -----------
> This SF.net email is sponsored by DB2 Express Download DB2=20
> Express C - the FREE version of DB2 express and take control=20
> of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>=20
>=20
|