Florian,

I think that you need to add the ax.titleOffsetTrans to the ax.transAxes 
transformation.

ax.text(0,pos[1],letter,transform=ax.transAxes+ax.titleOffsetTrans,va=va)

-Sterling

On Mar 17, 2014, at 6:31AM, Florian M. Wagner wrote:

> Dear users,
> 
> I would like label my subplots with a horizontally left-aligned letter 
> (wanted by the journal) and the normal, centered axes title, which should 
> both be vertically in line. The following example does not work: 
> 
> from matplotlib import pyplot as plt
> import numpy as np
> 
> fig, ax1 = plt.subplots()
> x = np.linspace(1,10)
> y = (sin(x))
> ax1.plot(x,y)
> 
> def subplot_label(ax, letter, title):
>     title = ax.set_title(title)
>     pos = title.get_position()
>     va = title.get_va()
>     ax.text(0, pos[1], letter, transform=ax.transAxes, verticalalignment=va)
>  
> subplot_label(ax1, 'a)', 'This text is not aligned with the label')
> 
> Which property of the axes title am I missing?
> 
> Thank you for your help
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to