Re: [Matplotlib-users] Centering Text with axes_divider

2012-03-10 Thread Jae-Joon Lee
I wonder why the simple text command does not work for you? e.g.,

def add_center_text(ax):
ax.text(0.5, 0.9075, Centered Title, ha='center', va='center',
fontsize=18,
bbox=dict(boxstyle='round, pad=0.5, rounding_size=0.25', fc=white,
  ec=k, lw=2),
transform=ax.transAxes)

Also, annotate command gives you more flexibility in text positioning.

The axes location is supposed to be known during the drawing time. To
get the axes position, you may do  something like

   ax1._axes_locator(ax1, fig._cachedRenderer)

Of course, this need to be done after the figure is properly drawn
(e.g., after calling draw()) or during the drawing time.

Regards,

-JJ


On Sat, Mar 10, 2012 at 1:00 PM, Patrick Marsh patrickmars...@gmail.com wrote:
 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 patrickmars...@gmail.com
 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@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Centering Text with axes_divider

2012-03-10 Thread Patrick Marsh
Hi, JJ,

I wonder why the simple text command does not work for you? e.g.,

 def add_center_text(ax):
ax.text(0.5, 0.9075, Centered Title, ha='center', va='center',
 fontsize=18,
bbox=dict(boxstyle='round, pad=0.5, rounding_size=0.25',
 fc=white,
  ec=k, lw=2),
transform=ax.transAxes)


The simple answer here is that I didn't understand what the transform
keyword argument was doing. I'm not entirely sure, still, but I gather it
has something to do with handling the changing of the axes coordinates.
 Man, I still have so much to learn about MPL


Also, annotate command gives you more flexibility in text positioning.

 The axes location is supposed to be known during the drawing time. To
 get the axes position, you may do  something like

   ax1._axes_locator(ax1, fig._cachedRenderer)

 Of course, this need to be done after the figure is properly drawn
 (e.g., after calling draw()) or during the drawing time.


Excellent. Thank you fot taking the time to explain how this works.
Although your first suggestion is what I need for the moment, I'm glad to
know how to get the axes positions, should I ever need them.


Thanks again!


Patrick
--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] custom markers from images?

2012-03-10 Thread Jae-Joon Lee
One way to use images as a marker would be to use offsetbox module.
Here is an example adopted from

http://matplotlib.sourceforge.net/examples/pylab_examples/demo_annotation_box.html

Regards,

-JJ


import matplotlib.pyplot as plt
from matplotlib.offsetbox import OffsetImage, AnnotationBbox
from matplotlib.cbook import get_sample_data

import numpy as np

if 1:
fig = plt.gcf()
fig.clf()
ax = plt.subplot(111)


xy = [0.3, 0.55]

arr = np.arange(100).reshape((10,10))
im = OffsetImage(arr, zoom=2)

ab = AnnotationBbox(im, xy,
xycoords='data',
pad=0.3,
)

ax.add_artist(ab)


# another image


from matplotlib._png import read_png
fn = get_sample_data(lena.png, asfileobj=False)
arr_lena = read_png(fn)

imagebox = OffsetImage(arr_lena, zoom=0.1)

xy = (0.7, 0.4)
ab = AnnotationBbox(imagebox, xy,
xycoords='data',
pad=0.5,
)


ax.add_artist(ab)

ax.set_xlim(0, 1)
ax.set_ylim(0, 1)


plt.draw()
plt.show()




On Thu, Mar 8, 2012 at 4:25 AM, Michael Droettboom md...@stsci.edu wrote:
 It would be a nice idea.  I'm not sure it's something that would work
 terribly well in vector backends as the images may not scale well.  I should
 mention that there is already support to use arbitrary Unicode characters or
 math expressions as markers already, which does work well in vector
 backends.

 Mike


 On 03/07/2012 01:59 PM, C M wrote:

 I've for now taken a different approach that means I won't need custom
 markers from images.

 But I'm just curious:  is there any wish/plans in Matplotlib to add support
 for this?  I think it could do a lot to expand what's possible in terms of
 the look and feel of plots (even without things drifing into USA Today
 territory!).

 Just my $0.02

 Che


 --
 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@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



 --
 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@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Runtime error with matplotlib in IDLE

2012-03-10 Thread Catherine Thwaites
I have an error when running my script using matplotlib using IDLE. I
suspect it is something to do with either numpy or matplotlib and I was
wondering if any other users have had a similar problem. I have recently
installed Python, matplotlib and numpy, I have not had it working correctly
using IDLE on this machine. The error message is:

Runtime Error!

Program: C:\Python27\pythonw.exe

This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's supporter team for more information.

The window header says Microsoft Visual C++ Runtime Library (which seems to
be about debugging). The error occurs about 50% of the time. When I run my
script in the command line it runs fine everytime. I am using matplotlib
and generating a pdf. If I remove the pdf generation step I still get the
error. But running another script (on the csv module) don't seem to
generate the error. I have searched on the internet without luck
(suggestion of installing visual studio which I have got) or posting to the
scipy list (well Im not using scipy).

I am using Win7 32 bit and matplotlib 1.1 and numpy 1.6.1 and python 2.7.
Has anyone else had similar message?

Catherine
--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Set various parameters of a plot window.

2012-03-10 Thread Ignas Anikevicius
Hello everybody,

I am trying to write a rule for AwesomeWM, so that all matplotlib
related windows would be floating and not tiled. For this purpose I want
to filter matplotlib windows by some window attribute, like class,
instance or title. Is there a way to modify the window class or instance
easily?

I already know how to modify the title of the window, but this is not
sufficient as any dialogs, which would be created from the toolbar on
the plot window will not have the same title and the filtering can not
be applied to them.

If I have not explained this clearly enough, please let me know, what
I need to clarify.

All best,
Ignas A.

--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users