[Matplotlib-users] Down Another Pathway with Plot-Show

2010-02-12 Thread Wayne Watson
Certainly in IDLE, when one hits a show() in a def, the program does not 
continue to the next statement. It goes somewhere else, because my 
program continues normally. Apparently, it goes back up the def calls to 
the "main" program, which is a loop that just reads the next file to 
perform more of what I expect.  If I know this to be true*, that allows 
a "workaround" with globals.

* There is another def that uses plot-show, and it continues without any 
notable difficulty. The show() is the last statement in the def. Of  
course, since show() is a  legitimate use, if one knows the "end" rule, 
this seems quite reasonable way to operate.
-- 
"Crime is way down. War is declining. And that's far from the good 
news." -- Steven Pinker (and other sources) Why is this true, but yet 
the media says otherwise? The media knows very well how to manipulate us 
(see limbic, emotion, $$). -- WTW

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] My matplotlib To-Do List

2010-02-12 Thread Wayne Watson
Thanks. True enough. I've been exploring that  possibility, and it is 
probably the way to go.  When I get a little further down the line, I'll 
probably distribute it that  way.

On 2/12/2010 9:35 AM, Christopher Barker wrote:
> Wayne Watson wrote:
>
>> So  here's my list of thing to do when I come back to it.
>>  
> good plan, one comment:
>
>
>> Determine if a better interpreter tool than IDLE would satisfy the end
>> users of the program I'm modifying. The hurdle is non-Python users who
>> just fire up IDLE and execute the program via F5.
>>  
> This one is a no brainer -- IDLE is an Integrated Development
> Environment -- if you are not developing, you don't need it, t is NOT a
> tool to run simply run a python program. It's really not hard to run a
> python program.
>
> Note that py2exe and friends might be the best solution -- these are
> tools that build a self-contained executable from a python program, so
> you end up with something to double click on, just like any other program.
>
> I don't know about TkInter, but wxPython has an option where it will put
> up a message window to show the user standard output -- it sounds like
> you want the user to see messages, etc. Maybe TK has something similar.
>
> Good luck,
>
> -Chris
>
>
>
>
>

-- 
"Crime is way down. War is declining. And that's far from the good 
news." -- Steven Pinker (and other sources) Why is this true, but yet 
the media says otherwise? The media knows very well how to manipulate us 
(see limbic, emotion, $$). -- WTW

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Interpolation between points during plot()

2010-02-12 Thread T J
Hi,

When plotting,

plot(x, y, marker="-")

and its similar markers, what functionality in MPL is responsible for
interpolating between the points?  My naive guess is that
interpolation is done in "display" coordinates since everything looks
nice even when zooming in.I inquire because I'd like to make
interpolation between two points follow some other path between the
two points.  In other words, I'd like to make a plot structure which
will follow a different type of geodesic.  Any tips or pointers in the
right direction would be greatly appreciated.

Thanks!

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] help with a custom formatter

2010-02-12 Thread C M
I would like a custom formatter that does 3 things:

1) Blanks out all the values less than 0.
2) Chooses appropriate major ticks when zoomed out.
3) Shows an integer when the zoom scale is revealing multiple
integers, but shows a decimal number when it is just showing within
one integer; i.e. if it is 1, 2, 3, 4  in first case but 1.1, 1.2,
1.3, 1.4 in the second.

So far I have needs (1) and (2) of this with this super-simple custom formatter:

class MyFormatter(ScalarFormatter):
def __call__(self, val, pos=None):
if val < 0:
return ''
else:
return int(val)

But how can I get need (3)?  I need to know what the view_interval is
to set a rule for this.  Something like:

if view_interval < 1:
return val   #this will be a decimal number
else:
return int(val)  #an integer

So how do I get the view_interval?  I'm not understanding how to get
that from matplotlib.ticker.TickHelper()--if that is even the right
way to do it--because get_view_interval() is not a method of
TickHelper but of "DummyAxis", and at that point I've lost the idea.

Any help is appreciated.  Thanks,
Che

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] make autoscale_view even less tight?

2010-02-12 Thread C M
On Fri, Feb 12, 2010 at 2:24 PM, Stan West  wrote:
>> From: C M [mailto:cmpyt...@gmail.com]
>> Sent: Wednesday, February 03, 2010 21:59
>>
>> I'm using autoscale_view for the y axis, but find with a marker size >
>> about 10, it will autoscale the graphs such that some markers are
>> bisected by the edges of the frame.  I already have it set to:
>>
>>     self.subplot.autoscale_view(tight=False, scalex=False,
>> scaley=True)
>>
>> so I'd basically like "tight" here to be "even less tight".  For
>> example, for a graph of time in minutes along the y axis, I'd like the
>> bottom of the graph to actually be a bit below zero to catch events
>> that are 0.5 min, etc., without them being half-buried under the edge
>> of the graph.
>>
>> Can autoscale_view be altered a bit to allow for a more generous view?
>
> For a similar requirement, I made the following custom locator:

Thank you.  I've been playing around with a way to do this, and may
have something working now from my attempt to modify the
autoscale_view function in axes.py.  My own re-write is below. It's
barely different from what is in the original function.  It just gets
the two edges of the bounding box that contains all the lines and
moves them out a bit.

I would like to understand your approach better.  So far, I can't get
your code to produce the "margins" indicated--but I'm probably
applying it wrongly.  I don't know how to force an autoscale, for
example.  Your code is tough for me to understand because there are a
number of things you make use of that I'm not familiar with yet. I
could ask a number of questions but don't want to burden the list with
that unless people are up for it.

Thanks,
Che

#  autoscale_view function that allows looser edges.

def loose_autoscale_view(self, subplot, margin, tight=False,
scalex=True, scaley=True):
"""
autoscale the view limits using the data limits. You can
selectively autoscale only a single axis, eg, the xaxis by
setting *scaley* to *False*.  The autoscaling preserves any
axis direction reversal that has already been done.

"""
# if image data only just use the datalim
if not self.subplot._autoscaleon: return
if scalex:
xshared = self.subplot._shared_x_axes.get_siblings(self.subplot)
dl = [ax.dataLim for ax in xshared]
bb = mtransforms.BboxBase.union(dl)
xdiff = bb.intervalx[1] - bb.intervalx[0]
x0 = bb.intervalx[0]-xdiff * margin
x1 = bb.intervalx[1]+xdiff * margin
if scaley:
yshared = self.subplot._shared_y_axes.get_siblings(self.subplot)
dl = [ax.dataLim for ax in yshared]
bb = mtransforms.BboxBase.union(dl)
y0 = bb.intervaly[0]-(bb.intervaly[1]* margin)
y1 = bb.intervaly[1]* (1+margin)

if (tight or (len(self.subplot.images)>0 and
  len(self.subplot.lines)==0 and
  len(self.subplot.patches)==0)):
if scalex:
self.subplot.set_xbound(x0, x1)
if scaley:
self.subplot.set_ybound(y0, y1)
return

if scalex:
XL = self.subplot.xaxis.get_major_locator().view_limits(x0, x1)
self.subplot.set_xbound(XL)
if scaley:
YL = self.subplot.yaxis.get_major_locator().view_limits(y0, y1)
self.subplot.set_ybound(YL)

#Then it would be called with:

self.loose_autoscale_view(self.subplot, 0.02, tight=False,
scalex=True, scaley=True)

#where self.subplot is my axes object.  (self is a panel class)

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] make autoscale_view even less tight?

2010-02-12 Thread Stan West
> From: C M [mailto:cmpyt...@gmail.com] 
> Sent: Wednesday, February 03, 2010 21:59
> 
> I'm using autoscale_view for the y axis, but find with a marker size >
> about 10, it will autoscale the graphs such that some markers are
> bisected by the edges of the frame.  I already have it set to:
> 
> self.subplot.autoscale_view(tight=False, scalex=False, 
> scaley=True)
> 
> so I'd basically like "tight" here to be "even less tight".  For
> example, for a graph of time in minutes along the y axis, I'd like the
> bottom of the graph to actually be a bit below zero to catch events
> that are 0.5 min, etc., without them being half-buried under the edge
> of the graph.
> 
> Can autoscale_view be altered a bit to allow for a more generous view?

For a similar requirement, I made the following custom locator:



import numpy as np
import matplotlib as mpl
import matplotlib.ticker as mticker
import matplotlib.transforms as mtransforms

class LooseMaxNLocator(mticker.MaxNLocator):

def __init__(self, margin = 0.05, **kwargs):
mticker.MaxNLocator.__init__(self, **kwargs)
self._margin = margin

def autoscale(self):
dmin, dmax = self.axis.get_data_interval()
if self._symmetric:
maxabs = max(abs(dmin), abs(dmax))
dmin = -maxabs
dmax = maxabs
dmin, dmax = mtransforms.nonsingular(dmin, dmax, expander = 0.05)
margin = self._margin * (dmax - dmin)
vmin = dmin - margin
vmax = dmax + margin
bin_boundaries = self.bin_boundaries(vmin, vmax)
vmin = min(vmin, max(bin_boundaries[bin_boundaries <= dmin]))
vmax = max(vmax, min(bin_boundaries[bin_boundaries >= dmax]))
return np.array([vmin, vmax])



The *margin* argument controls the looseness.  For a given axis *ax*, you
instantiate and apply the locator with something like

ax.xaxis.set_major_locator(LooseMaxNLocator(nbins=7, steps=[1, 2, 5, 10]))

and likewise for the Y axis.  I believe that if the plot has already been
drawn, you have to somehow force an autoscaling.

I wrote that about 1.5 years ago for an earlier version of matplotlib, and I
don't know how compatible it is with the current ticker.py code.  In
particular, you might need to override *view_limits* instead of *autoscale*.
Anyway, I hope it's useful to you.


--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How Does One Learn to Use MatPlotLib? (PUG)

2010-02-12 Thread Gökhan Sever
On Fri, Feb 12, 2010 at 10:37 AM, Wayne Watson  wrote:

> I'm beginning to read aboutPython OOP, classes, inheritance and the like.
> It seems like an understanding of those concepts is key to understanding how
> the import needs are met.
>
> --
> "Crime is way down. War is declining. And that's far from the good news."
> -- Steven Pinker (and other sources) Why is this true, but yet the media
> says otherwise? The media knows very well how to manipulate us (see limbic,
> emotion, $$). -- WTW
>

I suggest you studying these books:

http://homepage.mac.com/s_lott/books/index.html

I learnt a great deal of information from the Python for Programmers title.

Besides you can take a look at Fernando's starter page at
http://fperez.org/py4science/starter_kit.html You can find many valuable
general Python sources listed there (especially tutorial videos from
PyCon09)

I can also suggest you trying Eclipse + PyDev combination. PyDev makes
debugging and following the flow of your programs very easier. For instance;

Try:

import matplotlib.pypot as plt
plt.plot(range(10))
plt.show()

and set a breakpoint in the first line and step into the matplotlib code to
see how it flows.

-- 
Gökhan
--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] [SOT; Announce] Info about the API used in finance.quotes_historical_yahoo

2010-02-12 Thread David Goldsmith
Hi!  Originally, this was to be a question about where to get that described in 
the subject, but I realized: "hey, it's a yahoo! service and I haven't searched 
yahoo! yet"; sure enough I easily found:

http://www.gummy-stuff.org/Yahoo-data.htm

Jackpot!  All the free, detailed numerical stock data one could ever need (of 
course, I don't know about its QA/QC, but hey, it's free!)

FWIW to others,

DG

PS: Short of canceling my subscription via this address and resubscribing my 
other one, is there another way to change my subscription address?  Thanks!


  

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 16bit tiff support?

2010-02-12 Thread Eric Firing
Philipp Lies wrote:
> Hi,
> 
> is there a backend that supports 16bit tiff images?

Can you just use png, and use the netpbm utilities or ImageMagick 
convert program to go to and from tiff?

Eric

> According to the website GDK supports tiff but that's wrong:
> 
>  >>>import matplotlib
>  >>>matplotlib.use('GDK')
>  >>>import matplotlib.pyplot as pyplot
>  >>>pyplot.imsave(arr=X, fname='test.tif')
> Traceback (most recent call last):
> File "", line 1, in 
> File "/usr/lib/pymodules/python2.6/matplotlib/pyplot.py", line 1425, in 
> imsave
> return _imsave(*args, **kwargs)
> File "/usr/lib/pymodules/python2.6/matplotlib/image.py", line 813, in imsave
> fig.savefig(fname, dpi=1, format=format)
> File "/usr/lib/pymodules/python2.6/matplotlib/figure.py", line 1033, in 
> savefig
> self.canvas.print_figure(*args, **kwargs)
> File "/usr/lib/pymodules/python2.6/matplotlib/backend_bases.py", line 
> 1420, in print_figure
> '%s.' % (format, ', '.join(formats)))
> ValueError: Format "tif" is not supported.
> Supported formats: emf, eps, pdf, png, ps, raw, rgba, svg, svgz.
>  >>>matplotlib.backends.backend
> 'gdk'
> 
> matplotlib 0.99.0 python 2.6.4 ubuntu karmic x64
> 
> If matplotlib cannot provide tiff support, does someone know an 
> alternative? PIL doesn't work either, at least not intuitively.
> 
> Cheers
> 
> Philipp
> 


--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] figure aspect ratio

2010-02-12 Thread Tomasz Koziara
Hi

I would like to have a bar plot twice as heigh as it is wide. It seems  
though that setting the aspect ratio is nontrivial. I tried this:

   w, h = fig.figaspect (2.0)
   plt.figure().set_figheight (h)
   plt.figure().set_figwidth (w)

but then axis labels or even numbering gets cut off. On the other hand  
playing with:

plt.axes().set_aspect (2.0)

does amazingly strange things. The explanation about what the number  
in the set_aspect function should be is quite vogue in the  
documentation. Hence my questions:

How to specify the aspect ratio of a figure (in my case containing  
some bar plots) so that all remaining things (like axis labels) are  
respected in the final result?

Regards
Tomek

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Why do xticklabels and yticklabels always collide?

2010-02-12 Thread Jeremy Conlin
On Fri, Feb 12, 2010 at 11:30 AM, C M  wrote:
>> My biggest problem with matplotlib is that the smallest yticklabel and
>> the smallest xticklabel always seem to lie on top of each other (or
>> close to it).  See attachment for example.  Is there anyway to make it
>> so these don't lie on top of each other?  How can I make this the
>> default behavior?
>>
>> Thanks,
>> Jeremy
>
> This was just asked a day or two ago, and here's how that went:
>
> http://old.nabble.com/x%2Cy-ticklabel-too-close-to27551389.html

Oops I didn't notice the other message.  Sorry for asking again.

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Why do xticklabels and yticklabels always collide?

2010-02-12 Thread C M
> My biggest problem with matplotlib is that the smallest yticklabel and
> the smallest xticklabel always seem to lie on top of each other (or
> close to it).  See attachment for example.  Is there anyway to make it
> so these don't lie on top of each other?  How can I make this the
> default behavior?
>
> Thanks,
> Jeremy

This was just asked a day or two ago, and here's how that went:

http://old.nabble.com/x%2Cy-ticklabel-too-close-to27551389.html

I guess you could also change the LABELPAD value to bring the labels a
bit off the axes, so they can't collide, like:

axis.xaxis.LABELPAD = 8  #or however much you want

I don't know how you could make this default behavior, but making
matplotlib such that this was hard to do--instead of the
default--might be a useful improvement.

Che

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Why do xticklabels and yticklabels always collide?

2010-02-12 Thread Jeremy Conlin
My biggest problem with matplotlib is that the smallest yticklabel and
the smallest xticklabel always seem to lie on top of each other (or
close to it).  See attachment for example.  Is there anyway to make it
so these don't lie on top of each other?  How can I make this the
default behavior?

Thanks,
Jeremy


Burunp.pdf
Description: Adobe PDF document
--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] My matplotlib To-Do List

2010-02-12 Thread Christopher Barker
Wayne Watson wrote:
> So  here's my list of thing to do when I come back to it.

good plan, one comment:

> Determine if a better interpreter tool than IDLE would satisfy the end 
> users of the program I'm modifying. The hurdle is non-Python users who 
> just fire up IDLE and execute the program via F5.

This one is a no brainer -- IDLE is an Integrated Development 
Environment -- if you are not developing, you don't need it, t is NOT a 
tool to run simply run a python program. It's really not hard to run a 
python program.

Note that py2exe and friends might be the best solution -- these are 
tools that build a self-contained executable from a python program, so 
you end up with something to double click on, just like any other program.

I don't know about TkInter, but wxPython has an option where it will put 
up a message window to show the user standard output -- it sounds like 
you want the user to see messages, etc. Maybe TK has something similar.

Good luck,

-Chris




-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] My matplotlib To-Do List

2010-02-12 Thread Wayne Watson
I think I need a time out to consider my recent posts. This particular 
mod can wait while I get to other priority items into action again. So 
here's my list of thing to do when I come back to it.

Check out ipython more thoroughly.
Examine the backend concept
Read about the MPL interactive mode.
Look at the embedded app material in MPL.
Determine if a better interpreter tool than IDLE would satisfy the end 
users of the program I'm modifying. The hurdle is non-Python users who 
just fire up IDLE and execute the program via F5. That plus many are 
even reluctant to move from 2.4 to 2.5. New features could move that along.
Read the parts of the MPL Guide that I've culled out for my interests..
Attend a PUG meeting in the San Francisco Bay Area on the 25th.
Buy the (new) MPL book on Amazon if my local library can't get a loan of 
one of the two libraries in the US that has it.
Watch relevant videos from the 8th Annual Python in Science Conference

That should be enough, and should keep me busy when I expect to return 
to this in a few weeks. Thanks to the participants who responded to my 
posts.

-- 
"Crime is way down. War is declining. And that's far from the good 
news." -- Steven Pinker (and other sources) Why is this true, but yet 
the media says otherwise? The media knows very well how to manipulate us 
(see limbic, emotion, $$). -- WTW

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How Does One Learn to Use MatPlotLib? (PUG)

2010-02-12 Thread Wayne Watson
I'm beginning to read aboutPython OOP, classes, inheritance and the 
like. It seems like an understanding of those concepts is key to 
understanding how the import needs are met.
-- 
"Crime is way down. War is declining. And that's far from the good 
news." -- Steven Pinker (and other sources) Why is this true, but yet 
the media says otherwise? The media knows very well how to manipulate us 
(see limbic, emotion, $$). -- WTW

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] How to draw a rectangle using event handler ?

2010-02-12 Thread Yagua Rovi
Hello world!
I am displaying on my screen a set of data corresponding to points
defined by a longitude and latitude.
The display is fine with the command imshow (mydata ,...)

I would like now associate to the application  a callback that draw a rectangle
on two consecutive left mouse's button press defined by its two
opposite vertices.
(also returns points) and a right click button that erases the rectangle.

I found the event_handling example, but I do not know how to do this.
May someone helps me?
Thank's a lot in advance.

Yagua

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] PyCon

2010-02-12 Thread Ben Axelrod
Is anyone planning on attending PyCon in Atlanta next week? 
http://us.pycon.org/2010/about/
-Ben

Ben Axelrod
Robotics Engineer
(800) 641-2676 x737
[cid:484541315@12022010-129E]
www.coroware.com
www.corobot.net

<>--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] x,y ticklabel too close

2010-02-12 Thread Filipe Pires Alvarenga Fernandes
Thanks for all the suggestions,

Spines did the trick.

JJ, I would like to be able to contribute more, but my python knowledge is
very limited and I'm still a very Matlab oriented person.

Anyways, maybe people here might be interested in  my recent adventure
trying to learn python. I converted the CSIRO seawater library from matlab
to python.

http://www.cmar.csiro.au/datacentre/ext_docs/seawater.htm

I know that this is specific for oceanographers, but I saw some of us in
this list.


Thanks again, this list helped my a lot.


On Thu, Feb 11, 2010 at 12:40 PM, Filipe Pires Alvarenga Fernandes <
ocef...@gmail.com> wrote:

> Hello list,
>
> For the following plotI using a large font for the tick-label that causes
> the first x,y tick-labels to overlap
>
> http://yfrog.com/5zimageykp
>
> for now I'm padding spaces to "fix" the plot, like this:
>
> newtick = ["-10  ", "-5", "0   ", "5   ", "10 "]
> pos =[-10, -5, 0, 5, 10]
> yticks(pos, newtick)
>
> However I was wondering if there is any automatic way to avoid or fix this
> overlap.
>
> Thanks, Filipe
>
--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Selectable contour(f) divisions

2010-02-12 Thread Matthias Michler
On Friday 12 February 2010 15:11:17 Bruce Ford wrote:
> Thanks for this.  I didn't realize that N could be an array and
> contour would know that these are the levels desired.
>
> I found similar in an example, but not in the contour documentation.

Just a remark: I use the help of IPython to investigate the doc-strings of 
matplotlib-functions. The input "contour?" tells me 
::

  contour(Z,V)
  contour(X,Y,Z,V)

draw contour lines at the values specified in sequence *V*

Kind regards,
Matthias

> Thanks so much!
>
> Bruce

> On Fri, Feb 12, 2010 at 7:29 AM, Matthias Michler
>
>  wrote:
> > Hi Bruce,
> >
> > why don't you use contour as in the following ;-)
> >
> > contour(X,Y,Z,V)
> > # -> draw contour lines at the values specified in sequence *V*
> >
> > like in
> >
> > x, y = np.meshgrid(np.linspace(0, 1, 100), np.linspace(0, 1, 50))
> > z = x**4 - x**2 + np.sin(y)
> > contour(x, y, z, [-0.2, 0.0, 0.2, 0.4, 0.6, 0.8])
> >
> > Kind regards,
> > Matthias
> >
> > On Thursday 11 February 2010 21:58:15 Bruce Ford wrote:
> >> In using the contour as in:
> >>
> >> contour(X,Y,Z,N)
> >>
> >> N is a number of automatically chosen levels.
> >>
> >> I would like to contour based on data divisions.
> >>
> >> For instance, perhaps I'd like to use a contour or color-fill
> >> (contourf) every 2 units.  I'm not seeing how to accomplish this.  Any
> >> points in the right direction would be appreciated.
> >>
> >> Thanks!
> >>
> >> Bruce


--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Selectable contour(f) divisions

2010-02-12 Thread Bruce Ford
Thanks for this.  I didn't realize that N could be an array and
contour would know that these are the levels desired.

I found similar in an example, but not in the contour documentation.

Thanks so much!

Bruce
---
Bruce W. Ford
Clear Science, Inc.
br...@clearscienceinc.com
bruce.w.ford@navy.smil.mil
http://www.ClearScienceInc.com
Phone/Fax: 904-379-9704
8241 Parkridge Circle N.
Jacksonville, FL  32211
Skype:  bruce.w.ford
Google Talk: for...@gmail.com



On Fri, Feb 12, 2010 at 7:29 AM, Matthias Michler
 wrote:
> Hi Bruce,
>
> why don't you use contour as in the following ;-)
>
> contour(X,Y,Z,V)
> # -> draw contour lines at the values specified in sequence *V*
>
> like in
>
> x, y = np.meshgrid(np.linspace(0, 1, 100), np.linspace(0, 1, 50))
> z = x**4 - x**2 + np.sin(y)
> contour(x, y, z, [-0.2, 0.0, 0.2, 0.4, 0.6, 0.8])
>
> Kind regards,
> Matthias
>
> On Thursday 11 February 2010 21:58:15 Bruce Ford wrote:
>> In using the contour as in:
>>
>> contour(X,Y,Z,N)
>>
>> N is a number of automatically chosen levels.
>>
>> I would like to contour based on data divisions.
>>
>> For instance, perhaps I'd like to use a contour or color-fill
>> (contourf) every 2 units.  I'm not seeing how to accomplish this.  Any
>> points in the right direction would be appreciated.
>>
>> Thanks!
>>
>> Bruce
>
>
> --
> SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
> http://p.sf.net/sfu/solaris-dev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Memory leak when destroying Tk frame containing a figure

2010-02-12 Thread Stephan Markus
Calling the garbage collector (gc.collect()) also makes no difference.
Even deleting all references manually and dropping the toolbar code
doesn't do the trick.


Am 09.02.2010 16:19, schrieb Stephan Markus:
> I already had my destroy() method look like this:
>
> def destroy(self):
> self.f.clf()
> Tix.Frame.destroy(self)
> self.toolbar.destroy()
> self.canvas._tkcanvas.destroy()
>
>
> But it makes no difference.
>
> Stephan
>
> Am 08.02.2010 17:15, schrieb Michael Droettboom:
>   
>> Have you tried explicitly calling .clf() on the matplotlib Figure object 
>> from your Tix.Frame.destroy callback?
>>
>> Mike
>>
>>   
>> 


--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Selectable contour(f) divisions

2010-02-12 Thread Matthias Michler
Hi Bruce,

why don't you use contour as in the following ;-) 

contour(X,Y,Z,V)
# -> draw contour lines at the values specified in sequence *V*

like in

x, y = np.meshgrid(np.linspace(0, 1, 100), np.linspace(0, 1, 50))
z = x**4 - x**2 + np.sin(y)
contour(x, y, z, [-0.2, 0.0, 0.2, 0.4, 0.6, 0.8])

Kind regards,
Matthias

On Thursday 11 February 2010 21:58:15 Bruce Ford wrote:
> In using the contour as in:
>
> contour(X,Y,Z,N)
>
> N is a number of automatically chosen levels.
>
> I would like to contour based on data divisions.
>
> For instance, perhaps I'd like to use a contour or color-fill
> (contourf) every 2 units.  I'm not seeing how to accomplish this.  Any
> points in the right direction would be appreciated.
>
> Thanks!
>
> Bruce


--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Maximize plotwindow & hot to plot figure by figure?

2010-02-12 Thread Matthias Michler
On Friday 12 February 2010 00:36:41 zxc wrote:
> 2 Problems:
>
> 1. How is it possible to maximize the window of the plot?
If the window is open and you are in the mainloop ypu can press ' f ' for 
fullscreen mode. Furthmore you can modify the figure-size by 
figure(figsize=(16, 8))

> 2. First I want to plot only figure 0, after 5 seconds figure 0 has to be
> closed and figure 1 to be shown.
>
> Any suggestions?

for the second point I attached an example which uses an earlier 'draw' to 
actually show the first figure in interactive mode.
Furthermore I proposed an example without generating new figures and reusing 
one figure.

Kind regards,
Matthias


> from pylab import *
> import time
>
> ion()
>
> figure(0)
> plot([1,2,3])
>
> figure(1)
> plot([10, 20, 30])
>
> figure(0)
> plot([4, 5, 6])
>
> figure(1)
> plot([40, 50, 60])
>
>
> draw(0)
> time.sleep(5)
> close()
>
>
> draw(1)
>
> show()




figure_by_figure.py
Description: application/python
--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] 16bit tiff support?

2010-02-12 Thread Philipp Lies
Hi,

is there a backend that supports 16bit tiff images?
According to the website GDK supports tiff but that's wrong:

 >>>import matplotlib
 >>>matplotlib.use('GDK')
 >>>import matplotlib.pyplot as pyplot
 >>>pyplot.imsave(arr=X, fname='test.tif')
Traceback (most recent call last):
File "", line 1, in 
File "/usr/lib/pymodules/python2.6/matplotlib/pyplot.py", line 1425, in 
imsave
return _imsave(*args, **kwargs)
File "/usr/lib/pymodules/python2.6/matplotlib/image.py", line 813, in imsave
fig.savefig(fname, dpi=1, format=format)
File "/usr/lib/pymodules/python2.6/matplotlib/figure.py", line 1033, in 
savefig
self.canvas.print_figure(*args, **kwargs)
File "/usr/lib/pymodules/python2.6/matplotlib/backend_bases.py", line 
1420, in print_figure
'%s.' % (format, ', '.join(formats)))
ValueError: Format "tif" is not supported.
Supported formats: emf, eps, pdf, png, ps, raw, rgba, svg, svgz.
 >>>matplotlib.backends.backend
'gdk'

matplotlib 0.99.0 python 2.6.4 ubuntu karmic x64

If matplotlib cannot provide tiff support, does someone know an 
alternative? PIL doesn't work either, at least not intuitively.

Cheers

Philipp

-- 
Philipp Lies

Max Planck Institute for Biological Cybernetics
Computational Vision & Neuroscience Group
Spemannstr. 41
D-72076 Tuebingen
Germany

Phone:  +49-7071-601-1788
Fax:+49-7071-601-552
E-Mail: philipp.l...@tuebingen.mpg.de
http://www.kyb.mpg.de/bethgegroup

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Legend placement on graphs with fill_between

2010-02-12 Thread Geoff Bache
On Thu, Feb 11, 2010 at 4:58 PM, John Hunter  wrote:
> On Thu, Feb 11, 2010 at 9:43 AM, Geoff Bache  wrote:
>>
>> Hi all,
>>
>> I'm trying to generate graphs from my test results, with regions
>> coloured with succeeded and failing tests. It nearly works, but I have
>> the following problem. I am providing the data with fill_between, which
>> returns PolyCollection objects which cannot be provided to a legend. So
>> I use the "proxy artist" trick, as described here
>>
>> http://matplotlib.sourceforge.net/users/legend_guide.html#plotting-guide-legend
>>

> The only reason fill_between uses a PolyCollection is to support the
> "where" keyword argument for non-contiguous fill regions, which you do
> not appear to be using.

Actually, not using it wasn't out of choice. I couldn't figure out how
to make it stop plotting at one point at start again at the next. In
my example, is there a way to plot the red regions using a single call
and "where"? I tried this

where = [False, True, True, True, False, True]
axessubplot4.fill_between([0, 1, 2, 3, 4, 5], [2, 2, 2, 8, 8, 15], [2,
2, 4, 8, 8, 18], where=where, color='#FF3118', linewidth=2,
linestyle='-')

but that fails to plot either to or from point 4, whereas actually I
just want it to leave out the region between points 3 and 4 (where the
values are equal)

Regards,
Geoff

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] How to blank an area of the canvas?

2010-02-12 Thread Brendan Barnwell
I'm trying to find the quickest way to erase a rectangular area of 
the figure canvas.  I tried using canvas.restore_region with the 
optional bbox argument, but there seems to be some mismatch between 
the measurement units of the saved buffer object and the currently 
shown data.  For instance, if I have a Text object on my plot, I tried 
this:

bbox = g.text.get_window_extent()
canvas.restore_region(background, bbox)

. . . but it does not correctly block out the text.  (The restored 
rectangle from the background appears elsewhere on the axes.)  How can 
I convert the buffer coordinates to the coordinates of the the 
displayed plot?

I also tried creating a patch with the same bounds as the text bbox 
and adding it to the axes, but this seems to have no effect.  Do I 
have to do something besides ax.draw_artist(mypatch) to get it to draw?

This is part of the same thing I posted about a few days ago with 
trying to do an animation with many moving parts.  Are there any 
examples of animations which do not involve restoring the entire 
background with each draw, but rather individually erasing individual 
elements in the plot and redrawing them elsewhere?  That's what I'm 
trying to do here.

Thanks,
-- 
Brendan Barnwell
"Do not follow where the path may lead.  Go, instead, where there is 
no path, and leave a trail."
--author unknown

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Legend placement on graphs with fill_between

2010-02-12 Thread Geoff Bache
Many thanks for the suggestions, will try these out today.

Incidentally, it looks like there is an interesting bug in the mail
archive software. Viewing my original message there I can see that it
has removed all instances of the combination "pre" (that's p then r
then e if it eats this too!). It does this even in the middle of
words, such as "previous", "appreciate" etc.

Regards,
Geoff

On Thu, Feb 11, 2010 at 6:44 PM, Jae-Joon Lee  wrote:
> Or, you may fool the algorithm to find the best location by adding
> invisible lines.
> For example,
>
> axessubplot4.set_autoscale_on(False)
> l1, = axessubplot4.plot([4, 5], [8, 18])
> l1.set_visible(False)
> axessubplot4.set_autoscale_on(True)
>
> Regards,
>
> -JJ
>
>
> On Thu, Feb 11, 2010 at 10:58 AM, John Hunter  wrote:
>> On Thu, Feb 11, 2010 at 9:43 AM, Geoff Bache  
>> wrote:
>>>
>>> Hi all,
>>>
>>> I'm trying to generate graphs from my test results, with regions
>>> coloured with succeeded and failing tests. It nearly works, but I have
>>> the following problem. I am providing the data with fill_between, which
>>> returns PolyCollection objects which cannot be provided to a legend. So
>>> I use the "proxy artist" trick, as described here
>>>
>>> http://matplotlib.sourceforge.net/users/legend_guide.html#plotting-guide-legend
>>>
>>
>> What about creating a proxy artist which is a simple polygon that has
>> the same outline as your fill_between polygon?
>>
>>
>> In [539]: t = np.arange(0, 1, 0.05)
>>
>> In [540]: y = np.sin(2*np.pi*t)
>>
>> In [541]: verts = zip(t, y)
>>
>> In [542]: proxy = mpatches.Polygon(verts, facecolor='yellow')
>>
>> The only reason fill_between uses a PolyCollection is to support the
>> "where" keyword argument for non-contiguous fill regions, which you do
>> not appear to be using.  Thus you could simply create the polygon
>> yourself with a little calculation (see mlab.poly_between for a helper
>> function) and then just add that patch to the axes rather than using
>> fill_between::
>>
>>  t = np.arange(0, 1, 0.05)
>>  ymin = np.sin(2*np.pi*t)-5
>>  ymax = np.sin(2*np.pi*t)+5
>>  xs, ys = mlab.poly_between(t, ymin, ymax)
>>  verts = zip(xs, ys)
>>  poly = mpatches.Polygon (verts, facecolor='red', label='my poly')
>>  ax = subplot(111)
>>  ax.add_patch(poly)
>>  ax.legend(loc='best')
>>  ax.axis([0, 1, -6, 6])
>>  plt.draw()
>>
>> --
>> SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
>> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
>> http://p.sf.net/sfu/solaris-dev2dev
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
> --
> SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
> http://p.sf.net/sfu/solaris-dev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users