WARNING: This server is unstable and will be retired in the next days. If you want to keep this forum available, please request immediately a migration on the Nabble Support forum. Forums that don't receive any migration request will be deleted forever.

 « Return to Thread: Centering Text with axes_divider

Re: Centering Text with axes_divider

by Patrick Marsh-2 :: Rate this Message:

| View in Thread

Hi, All,

Here's an update to the problem I submitted last night.

I was able to utilize anchored text to work for centering a title, which is ultimately what I'm wanting to do now. (Although, I'd still like to know the proper way to get the axes bounds when using axes_divider).  The new problem lies how to horizontally align the text inside the anchored box. When the horizontal alignment is "left", the text lines up in the anchored box. However, as the updated example below shows, then you use "center" or "right", the text is now positioned outside the anchored box.  Is this a bug in how the text is aligned? If so, how might I go about tracking it down?


https://gist.github.com/2004869 (rev: b984ca)


Cheers,
Patrick
---
Patrick Marsh
Ph.D. Student / Liaison to the HWT
School of Meteorology / University of Oklahoma
Cooperative Institute for Mesoscale Meteorological Studies
National Severe Storms Laboratory
http://www.patricktmarsh.com



On Fri, Mar 9, 2012 at 12:12 AM, Patrick Marsh <patrickmarshwx@...> wrote:
Greetings,

Let me begin by saying that I've fallen in love with ImageGrid. I love the control it gives me in setting up plots, and I really like the control it offers for setting up a colorbar. Unfortunately, like all relationships, ImageGrid and I have hit a rough patch.

I like to manually place titles and other boxes of texts on plots that I make using ImageGrid. However, to center things I have to know what the axes bounds are so I can do the centering calculations. Unfortunately, when using ImageGrid, or axes_divider, I have yet to find a way to get the axes bounds that are actually used to do the plotting. When I try to use 

ax.get_position().bounds

I get the pre-adjusted bounds, even if I use plt.draw() before requesting the axes_positions. This means the only way I can center the text is by guessing what the final axes bounds will be.  Is there any way of getting the final bounds? It appears anchored text is able to do it, but I haven't been able to...


Here's a self-contained example script that demonstrates the problem.  I don't use ImageGrid, instead using axes_divider, however this is the same problem that AxesGrid has. (I'm guessing this is because ImageGrid ultimately does what I did here behind the scenes.)

https://gist.github.com/2004869


Thanks for any help!


Patrick
---
Patrick Marsh
Ph.D. Student / Liaison to the HWT
School of Meteorology / University of Oklahoma
Cooperative Institute for Mesoscale Meteorological Studies
National Severe Storms Laboratory
http://www.patricktmarsh.com




------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

 « Return to Thread: Centering Text with axes_divider