python - Align matplotlib Text with colorbar -


i'd align bottom edge of text() instance bottom edge of colorbar instance, it's not working way expected:

i'm obtaining colorbar y position using cb.ax.get_position().ymin, , setting text object's y position so:

cb = plt.colorbar(mappable, shrink=0.5)  details = plt.text(     1., 1.,     "text",     ha='right', va='bottom',     size=5,     color='#555555',     transform=ax.transaxes,     fontdict={         'family': 'helvetica',         'size': 6}) details.set_y(cb.ax.get_position().ymin) 

i've tried altering va, 2 never aligned: using va=bottom middle of text appears aligned middle of colorbar; using va=center, text box ymin below (apparent) cb ymin. what's best way , set coordinates?

how look, directly plot cb.ax:

>>> x=linspace(-4,4) >>> y=linspace(-4,4) >>> g=meshgrid(x,y) >>> z=g[0]**2+5*g[1] >>> ctf=plt.contourf(x, y, z) >>> cb=plt.colorbar(ctf, shrink=0.5) >>> cb.ax.text(0.5, 0, 'text', va='top', ha='center') <matplotlib.text.text object @ 0x9173670> 

enter image description here


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -