Re: [Matplotlib-users] Hardware rendering with tricontourf

2012-01-27 Thread Ian Thomas
On 26 January 2012 19:36, Howard how...@renci.org wrote:

 I'm rendering some images with about 3.5 million triangles into a 512x512
 png file using tricontourf. I'm running this in a virtual machine, and I'm
 pretty sure that there is no graphics rendering hardware being used. Is it
 possible, assuming the hardware was available, to make tricontourf use the
 rendering hardware?  Will that happen by default?


You are correct, there is no graphics hardware rendering.  Rendering is
controlled by the various matplotlib backends, and to my knowledge there
are  no backends currently available that use hardware rendering.

There has been some work done on an OpenGL backend, but I am not sure of
the status of this.  The last time I checked it was pretty experimental.
Perhaps someone involved with it can comment on its current status.

Ian Thomas
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] four colour theorem

2012-01-27 Thread Eric Emsellem
Dear all,

I have a set of Voronoi bins, defined by nodes (x,y) and an underlying 
mesh of squared bins.
See an example here of such Voronoi bins.

http://www.google.fr/imgres?q=voronoi+binninghl=frsa=Xbiw=1280bih=665tbm=ischprmd=imvnsbtbnid=zp0RRIktKlF9pM:imgrefurl=http://www.aanda.org/articles/aa/full/2007/09/aa4621-05/aa4621-05.right.htmldocid=CeAk6FN_pZDa5Mimgurl=http://www.aanda.org/articles/aa/full/2007/09/aa4621-05/img26.gifw=532h=1087ei=ZmYiT-Z7xYDyA9ew0acMzoom=1iact=rcdur=164sig=112304340793152029504page=4tbnh=151tbnw=74start=63ndsp=25ved=1t:429,r:1,s:63tx=58ty=65

So basically each node, (x,y) would define a Voronoi bin made of a set 
of squared pixels. So one node would correspond to for example N squared 
pixels:

node[i] = [(x1,y1),(x2,y2),...(xN,yN)]

I want now to create an imshow like plot of these bins by using the four 
colour theorem, meaning that I would use 4 colours and want adjacent 
Voronoi bins not to have the same colour.

Is there a simple way to do this in matplotlib? I couldn't find much on 
the web so far.

thanks!
Eric


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Events

2012-01-27 Thread Jerzy Karczmarczuk
Benjamin Root answers my query concerning user-generated events :
 To answer your question, take a look at how pick_event() is declared 
 in backend_bases.py:

 def pick_event(self, mouseevent, artist, **kwargs):
  ...
 self.callbacks.process(s, event)

 The function that fires the event is self.callbacks.process(s, 
 event), where self is the figure canvas.
Dear Ben, thank you, but this is not exactly my problem. I don't want to 
call the callback myself, since the event should be fired from within 
a callback. I should have been more precise. Let's distil the problem. 
[This is a part of my current teaching...] I did already what you 
suggest here...

Imagine an animation, which consists in generating a trajectory, segment 
after segment (say, of a planet). Classically this is a loop, but when 
it runs, the rest of the program is blocked. So, instead, the code 
behaves as a Python generator, generates just one segment, and that's 
all. But it yields something, it posts an event, put it in a queue, 
and somebody else, the mainloop() or similar, pops it off the queue and 
re-launches the callback. (With generators, it calls the .next()). No 
timers, as in Timer or Funct animations...

It must be decentralized, no recursive calls. My callback from time to 
time creates another planet, or destroys an existent, and there are 
simultaneous trajectories on the screen, several concurrent events in 
the queue. And the system should remain reactive, interpret buttons, 
sliders, etc.

I know how to do this by hand, how to write my own event loop, declare a 
queue, and how to add to my private virtual event handling also the 
callbacks of mouse events. But this is an overkill, I  repeat the 
functionalities which are already there, the event queue in particular.

I did it with wx. But Matplotlib protects the user from the concrete 
back-end, and I want to protect my students as well, so I look for a 
GUI-neutral solution.

Thanks.

Jerzy



--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Overlaying part of an matrix image on another.

2012-01-27 Thread Pål Gunnar Ellingsen
Hi

I have a array, M, which is (4Nx4M), and an array (image), im, which is NxM.
I can currently plot the matrix as a 2d image using imshow using:

import matplotlib.pyplot as plt
from matplotlib import cm

# some code for reading in the matrix

cmap = cm.get_cmap('jet', 256)
imM = plt.imshow(M, cmap=cmap, vmin= -1, vmax=1)

But now i would like to plot im on top of M, such that it covers the firs
element of M.
If I do

plt.hold()
plt.imshow(im)

I only see im, and not M. I'm used to doing this in Matlab, where this
would work.

Can anyone explain me what I'm doing wrong?


Kind Regards
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Overlaying part of an matrix image on another.

2012-01-27 Thread Tony Yu
On Fri, Jan 27, 2012 at 9:13 AM, Pål Gunnar Ellingsen paa...@gmail.comwrote:

 Hi

 I have a array, M, which is (4Nx4M), and an array (image), im, which is
 NxM.
 I can currently plot the matrix as a 2d image using imshow using:

 import matplotlib.pyplot as plt
 from matplotlib import cm

 # some code for reading in the matrix

 cmap = cm.get_cmap('jet', 256)
 imM = plt.imshow(M, cmap=cmap, vmin= -1, vmax=1)

 But now i would like to plot im on top of M, such that it covers the firs
 element of M.
 If I do

 plt.hold()
 plt.imshow(im)

 I only see im, and not M. I'm used to doing this in Matlab, where this
 would work.

 Can anyone explain me what I'm doing wrong?


 Kind Regards


A call to `plt.autoscale` should fix your problem. It looks like `imshow`
rescales the axes limits to the current image limits, instead of the limits
for all the data in the axes. (Executable example below; note, axes hold
by default, so it's not necessary to call hold).

-Tony



import numpy as np
import matplotlib.pyplot as plt

background = np.random.uniform(0, 255, size=(20, 20))
overlay = np.arange(25).reshape((5, 5))

plt.imshow(background, interpolation='nearest', cmap=plt.cm.gray)
plt.imshow(overlay, cmap=plt.cm.jet, alpha=0.5)
# You could also replace this with `plt.axis([0, 20, 0, 20])
plt.autoscale()
plt.show()
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] four colour theorem

2012-01-27 Thread Benjamin Root
On Friday, January 27, 2012, Eric Emsellem eemse...@eso.org wrote:
 Dear all,

 I have a set of Voronoi bins, defined by nodes (x,y) and an underlying
 mesh of squared bins.
 See an example here of such Voronoi bins.


http://www.google.fr/imgres?q=voronoi+binninghl=frsa=Xbiw=1280bih=665tbm=ischprmd=imvnsbtbnid=zp0RRIktKlF9pM:imgrefurl=http://www.aanda.org/articles/aa/full/2007/09/aa4621-05/aa4621-05.right.htmldocid=CeAk6FN_pZDa5Mimgurl=http://www.aanda.org/articles/aa/full/2007/09/aa4621-05/img26.gifw=532h=1087ei=ZmYiT-Z7xYDyA9ew0acMzoom=1iact=rcdur=164sig=112304340793152029504page=4tbnh=151tbnw=74start=63ndsp=25ved=1t:429,r:1,s:63tx=58ty=65

 So basically each node, (x,y) would define a Voronoi bin made of a set
 of squared pixels. So one node would correspond to for example N squared
 pixels:

 node[i] = [(x1,y1),(x2,y2),...(xN,yN)]

 I want now to create an imshow like plot of these bins by using the four
 colour theorem, meaning that I would use 4 colours and want adjacent
 Voronoi bins not to have the same colour.

 Is there a simple way to do this in matplotlib? I couldn't find much on
 the web so far.

 thanks!
 Eric


None that I am aware of, but if one existed, it would likely be found
within the basemap module.  If it isn't in the Basemap module, it would be
an awesome feature to add.  Maybe something that would work with my
style-cycling mechanism that I have been tinkering with to allow for users
to specify 4 different hatchings for bw publications?

Cheers!
Ben Root
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] [matplotlib-users] How to plot y vs x with some missing points in y vector?

2012-01-27 Thread Fabien Lafont
I want to plot something like:


X(time)Ypoints
08
1
2 7
3
4
5
6
7
8
9

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [matplotlib-users] How to plot y vs x with some missing points in y vector?

2012-01-27 Thread Fabien Lafont
Sorry, It's an awkward manipulation. I finish the mail

2012/1/27 Fabien Lafont lafont.fab...@gmail.com:
 I want to plot something like:


 X(time)        Ypoints
 0                    8
 1
 2                    7
 36
 44
 5
 6
 77
 82
 9   10

In fact I've recorded some live datas and when I use genfromtxt() the
blank parts are translated as 'nan' and I can't for example fit it
with polynomials.

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [matplotlib-users] How to plot y vs x with some missing points in y vector?

2012-01-27 Thread Benjamin Root
On Fri, Jan 27, 2012 at 9:52 AM, Fabien Lafont lafont.fab...@gmail.comwrote:

 Sorry, It's an awkward manipulation. I finish the mail

 2012/1/27 Fabien Lafont lafont.fab...@gmail.com:
  I want to plot something like:
 
 
  X(time)Ypoints
  08
  1
  27
  36
  44
  5
  6
  77
  82
  9   10

 In fact I've recorded some live datas and when I use genfromtxt() the
 blank parts are translated as 'nan' and I can't for example fit it
 with polynomials.


If you plot the data, it should skip data points that are NaNs and you
should see a break in the line IIRC.  Is that not what you want?

Ben Root
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Hardware rendering with tricontourf

2012-01-27 Thread Howard

On 1/27/12 3:39 AM, Ian Thomas wrote:
On 26 January 2012 19:36, Howard how...@renci.org 
mailto:how...@renci.org wrote:


I'm rendering some images with about 3.5 million triangles into a
512x512 png file using tricontourf. I'm running this in a virtual
machine, and I'm pretty sure that there is no graphics rendering
hardware being used. Is it possible, assuming the hardware was
available, to make tricontourf use the rendering hardware?  Will
that happen by default?


You are correct, there is no graphics hardware rendering.  Rendering 
is controlled by the various matplotlib backends, and to my knowledge 
there are  no backends currently available that use hardware rendering.


There has been some work done on an OpenGL backend, but I am not sure 
of the status of this.  The last time I checked it was pretty 
experimental.  Perhaps someone involved with it can comment on its 
current status.


Ian Thomas

Ian

Thanks very much for the reply. If it helps whoever is doing the OpenGL 
backend, I may be able to play with it a bit.


Howard

--
Howard Lander mailto:how...@renci.org
Senior Research Software Developer
Renaissance Computing Institute (RENCI) http://www.renci.org
The University of North Carolina at Chapel Hill
Duke University
North Carolina State University
100 Europa Drive
Suite 540
Chapel Hill, NC 27517
919-445-9651
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [matplotlib-users] How to plot y vs x with some missing points in y vector?

2012-01-27 Thread Fabien Lafont
Yes in fact it plot it well, but then I have a vector like:
[3702.13999, nan, nan, nan, 3703.79, nan, nan, nan,
3704.69001, 3704.84001]
and it's impossible to fit it. It return 'nan'.

Ive tried:

for i in range(0,NbPts):
if column1[i] == nan:
column1[i].remove(nan)
column2[i].remove(nan)

to remove these points but it doesn't work


2012/1/27 Benjamin Root ben.r...@ou.edu:
 On Fri, Jan 27, 2012 at 9:52 AM, Fabien Lafont lafont.fab...@gmail.com
 wrote:

 Sorry, It's an awkward manipulation. I finish the mail

 2012/1/27 Fabien Lafont lafont.fab...@gmail.com:
  I want to plot something like:
 
 
  X(time)        Ypoints
  0                    8
  1
  2                    7
  3                    6
  4                    4
  5
  6
  7                    7
  8                    2
  9                   10

 In fact I've recorded some live datas and when I use genfromtxt() the
 blank parts are translated as 'nan' and I can't for example fit it
 with polynomials.


 If you plot the data, it should skip data points that are NaNs and you
 should see a break in the line IIRC.  Is that not what you want?

 Ben Root


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] (no subject)

2012-01-27 Thread nahren manuel
Dear Users,
I want to plot a XY, the X-value is constant, but let assume Y varees 
from 1-10, so I want o have different colors accordingly for the range 
0-2,2-4,4-6,6-8,8-10.

thanks a lot
najren
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [matplotlib-users] How to plot y vs x with some missing points in y vector?

2012-01-27 Thread Jérôme
Fri, 27 Jan 2012 16:48:25 +0100
Fabien Lafont a écrit:

 I want to plot something like:
 
 
 X(time)Ypoints
 08
 1
 2 7
 3
 4
 5
 6
 7
 8
 9

Sorry if I'm missing something, but can't you plot Y [8,7] against X [0,2] ?

-- 
Jérôme

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [matplotlib-users] How to plot y vs x with some missing points in y vector?

2012-01-27 Thread Benjamin Root
On Fri, Jan 27, 2012 at 10:11 AM, Fabien Lafont lafont.fab...@gmail.comwrote:

 Yes in fact it plot it well, but then I have a vector like:
 [3702.13999, nan, nan, nan, 3703.79, nan, nan, nan,
 3704.69001, 3704.84001]
 and it's impossible to fit it. It return 'nan'.

 Ive tried:

 for i in range(0,NbPts):
if column1[i] == nan:
column1[i].remove(nan)
column2[i].remove(nan)

 to remove these points but it doesn't work


You can't do equality tests with NaNs (us np.isnan(), instead).  This
question is more suited for the Numpy list.

Ben Root
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [matplotlib-users] How to plot y vs x with some missing points in y vector?

2012-01-27 Thread Fabrice Silva
What about masked arrays ?
http://docs.scipy.org/doc/numpy/reference/maskedarray.html


-- 
Fabrice Silva


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] histogram plots color range

2012-01-27 Thread nahren manuel
Hello ,
I have a two dimensional array, 40X20(rowsXcolumns). Each of the 40 rows 
themselves hold values of the bins of a distribution (which is not always 
normal, can expect a bimodal curve as well)

It is little difficult to explain to I actually created a sample figure:

http://www.flickr.com/photos/nahrenmascarenhas/6771369071/in/photostream

Any help or trick will be very useful

loads of thanks

nahren--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [matplotlib-users] How to plot y vs x with some missing points in y vector?

2012-01-27 Thread Fabien Lafont
Thanks a lot, I'll try to remove the points using isnan()

2012/1/27 Fabrice Silva si...@lma.cnrs-mrs.fr:
 What about masked arrays ?
 http://docs.scipy.org/doc/numpy/reference/maskedarray.html


 --
 Fabrice Silva


 --
 Try before you buy = See our experts in action!
 The most comprehensive online learning library for Microsoft developers
 is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
 Metro Style Apps, more. Free future releases when you subscribe now!
 http://p.sf.net/sfu/learndevnow-dev2
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [matplotlib-users] How to plot y vs x with some missing points in y vector?

2012-01-27 Thread Ethan Gutmann
On Jan 27, 2012, at 9:11 AM, Fabien Lafont wrote:

 Ive tried:
 
 for i in range(0,NbPts):
if column1[i] == nan:
column1[i].remove(nan)
column2[i].remove(nan)
 
 to remove these points but it doesn't work
 

you are close, I think what you want is: 

# assuming column1 and 2 are numpy arrays
import numpy as np

for i in range(0,NbPts):
   if np.isnan(column1[i]):
   column1=np.remove(column1,i,0)
   column1=np.remove(column2,i,0)

 
 2012/1/27 Benjamin Root ben.r...@ou.edu:
 On Fri, Jan 27, 2012 at 9:52 AM, Fabien Lafont lafont.fab...@gmail.com
 wrote:
 
 Sorry, It's an awkward manipulation. I finish the mail
 
 2012/1/27 Fabien Lafont lafont.fab...@gmail.com:
 I want to plot something like:
 
 
 X(time)Ypoints
 08
 1
 27
 36
 44
 5
 6
 77
 82
 9   10
 
 In fact I've recorded some live datas and when I use genfromtxt() the
 blank parts are translated as 'nan' and I can't for example fit it
 with polynomials.
 
 
 If you plot the data, it should skip data points that are NaNs and you
 should see a break in the line IIRC.  Is that not what you want?
 
 Ben Root
 
 
 --
 Try before you buy = See our experts in action!
 The most comprehensive online learning library for Microsoft developers
 is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
 Metro Style Apps, more. Free future releases when you subscribe now!
 http://p.sf.net/sfu/learndevnow-dev2
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Events

2012-01-27 Thread Tony Yu
On Fri, Jan 27, 2012 at 5:54 AM, Jerzy Karczmarczuk 
jerzy.karczmarc...@unicaen.fr wrote:

 Benjamin Root answers my query concerning user-generated events :
  To answer your question, take a look at how pick_event() is declared
  in backend_bases.py:
 
  def pick_event(self, mouseevent, artist, **kwargs):
   ...
  self.callbacks.process(s, event)
 
  The function that fires the event is self.callbacks.process(s,
  event), where self is the figure canvas.
 Dear Ben, thank you, but this is not exactly my problem. I don't want to
 call the callback myself, since the event should be fired from within
 a callback. I should have been more precise. Let's distil the problem.
 [This is a part of my current teaching...] I did already what you
 suggest here...

 Imagine an animation, which consists in generating a trajectory, segment
 after segment (say, of a planet). Classically this is a loop, but when
 it runs, the rest of the program is blocked. So, instead, the code
 behaves as a Python generator, generates just one segment, and that's
 all. But it yields something, it posts an event, put it in a queue,
 and somebody else, the mainloop() or similar, pops it off the queue and
 re-launches the callback. (With generators, it calls the .next()). No
 timers, as in Timer or Funct animations...

 It must be decentralized, no recursive calls. My callback from time to
 time creates another planet, or destroys an existent, and there are
 simultaneous trajectories on the screen, several concurrent events in
 the queue. And the system should remain reactive, interpret buttons,
 sliders, etc.

 I know how to do this by hand, how to write my own event loop, declare a
 queue, and how to add to my private virtual event handling also the
 callbacks of mouse events. But this is an overkill, I  repeat the
 functionalities which are already there, the event queue in particular.

 I did it with wx. But Matplotlib protects the user from the concrete
 back-end, and I want to protect my students as well, so I look for a
 GUI-neutral solution.

 Thanks.

 Jerzy


I'm not sure if this matches your use case, but have you looked into using
a coroutine. (I only recently learned about them---see presentation slides
linked on this page http://www.dabeaz.com/coroutines/. So obviously I'm
going out of my way to find a use case :)

I've attached a simple example below.

-Tony

#~~~

import matplotlib.pyplot as plt
import numpy as np


def datalistener():
fig, ax = plt.subplots()
line, = ax.plot(0, 0, 'o-')
i = 1
while True:
y0 = yield
x = np.hstack((line.get_xdata(), i))
y = np.hstack((line.get_ydata(), y0))
line.set_data((x, y))
ax.update_datalim(np.transpose((x, y)))
ax.autoscale_view()
plt.draw()
i += 1


plt.ion()
plotdata = datalistener()
# initialize the coroutine
plotdata.next()
while True:
y = raw_input('enter data point: ')
try:
plotdata.send(float(y))
except:
break
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] histogram plots color range

2012-01-27 Thread Tony Yu
On Fri, Jan 27, 2012 at 11:27 AM, nahren manuel meetnah...@yahoo.comwrote:

 Hello ,
 I have a two dimensional array, 40X20(rowsXcolumns). Each of the 40 rows
 themselves hold values of the bins of a distribution (which is not always
 normal, can expect a bimodal curve as well)
 It is little difficult to explain to I actually created a sample figure:
 http://www.flickr.com/photos/nahrenmascarenhas/6771369071/in/photostream

 Any help or trick will be very useful

 loads of thanks

 nahren


This plot seems similar to something I wanted to do (and asked the list
abouthttp://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg18761.html).
I ended up getting something to work, but the code is a bit ugly. I've
attached my most recent version (which probably needs some cleaning up, but
it works).

If you want a continuous field instead of distinct bars (like you have in
your sample image), you may be able to write up something that's a little
simpler by sectioning out the columns an array into strips of equal width
and repeating histogram values across those columns (sorry, this is a bit
vague). Then use `imshow` to plot the array.

-Tony


histstrip.py
Description: Binary data
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] histogram plots color range

2012-01-27 Thread josef . pktd
On Fri, Jan 27, 2012 at 12:18 PM, Tony Yu tsy...@gmail.com wrote:


 On Fri, Jan 27, 2012 at 11:27 AM, nahren manuel meetnah...@yahoo.com
 wrote:

 Hello ,
 I have a two dimensional array, 40X20(rowsXcolumns). Each of the 40 rows
 themselves hold values of the bins of a distribution (which is not always
 normal, can expect a bimodal curve as well)
 It is little difficult to explain to I actually created a sample figure:
 http://www.flickr.com/photos/nahrenmascarenhas/6771369071/in/photostream

 Any help or trick will be very useful

 loads of thanks

 nahren


 This plot seems similar to something I wanted to do (and asked the list
 about). I ended up getting something to work, but the code is a bit ugly.
 I've attached my most recent version (which probably needs some cleaning up,
 but it works).

 If you want a continuous field instead of distinct bars (like you have in
 your sample image), you may be able to write up something that's a little
 simpler by sectioning out the columns an array into strips of equal width
 and repeating histogram values across those columns (sorry, this is a bit
 vague). Then use `imshow` to plot the array.

Looks nice.

Given that it is too specialized for matplotlib, it would be an
interesting addition to violin and bean plots in scikits.statsmodels
if you don't mind that we borrow it (scikits.statsmodels is BSD
licensed).

Thanks,

Josef


 -Tony



 --
 Try before you buy = See our experts in action!
 The most comprehensive online learning library for Microsoft developers
 is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
 Metro Style Apps, more. Free future releases when you subscribe now!
 http://p.sf.net/sfu/learndevnow-dev2
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] histogram plots color range

2012-01-27 Thread Tony Yu
On Fri, Jan 27, 2012 at 4:01 PM, josef.p...@gmail.com wrote:

 On Fri, Jan 27, 2012 at 12:18 PM, Tony Yu tsy...@gmail.com wrote:
 
 
  On Fri, Jan 27, 2012 at 11:27 AM, nahren manuel meetnah...@yahoo.com
  wrote:
 
  Hello ,
  I have a two dimensional array, 40X20(rowsXcolumns). Each of the 40 rows
  themselves hold values of the bins of a distribution (which is not
 always
  normal, can expect a bimodal curve as well)
  It is little difficult to explain to I actually created a sample figure:
 
 http://www.flickr.com/photos/nahrenmascarenhas/6771369071/in/photostream
 
  Any help or trick will be very useful
 
  loads of thanks
 
  nahren
 
 
  This plot seems similar to something I wanted to do (and asked the list
  about). I ended up getting something to work, but the code is a bit ugly.
  I've attached my most recent version (which probably needs some cleaning
 up,
  but it works).
 
  If you want a continuous field instead of distinct bars (like you have in
  your sample image), you may be able to write up something that's a little
  simpler by sectioning out the columns an array into strips of equal width
  and repeating histogram values across those columns (sorry, this is a bit
  vague). Then use `imshow` to plot the array.

 Looks nice.

 Given that it is too specialized for matplotlib, it would be an
 interesting addition to violin and bean plots in scikits.statsmodels
 if you don't mind that we borrow it (scikits.statsmodels is BSD
 licensed).

 Thanks,

 Josef


Sure thing---I'm happy to contribute. The code probably needs to be cleaned
up, but unfortunately, I have little motivation since I don't use it
anymore. Feel free to do whatever you like with it.

Cheers,
-Tony
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Events

2012-01-27 Thread Jerzy Karczmarczuk
Tony Yu suggests that my multiple and changing animation problems could 
be solved using coroutining.
 have you looked into using a coroutine. /... /I've attached a simple 
 example below.

 import matplotlib.pyplot as plt
 import numpy as np
 def datalistener():
 ...
 while True:
 y0 = yield
 x = np.hstack((line.get_xdata(), i))
   ...
 plt.ion()
 ...
Thank you Tony. No, unfortunately this is again a side solution. Of 
course, coroutines, or just a simple event loop using Python generators 
without .send(), are perfectly decent tools to simulate parallel 
movements. But, coroutines as such, are better adapted to situations 
where the actors transfer the control among themselves, where there is a 
network of direct communications, a multi-ping-pong.
In my case this is redundant, my planets which move concurrently are 
independent, and they, after having updated their properties, need only 
to yield the control to the interface, to draw them. The interface 
resumes (by calling, no .send() is needed) all the actors in sequence. I 
repeat again : I COULD have written my own event loop (under ion()).

But I don't want to do this, since show() which calls some lower level 
mainloop() does all this already!

In particular, it handles the physical events, all mousing, which need 
anyway some lower-level mechanisms, and my own coroutines won't help. I 
MUST use the built-in tools in order to handle the mouse.

So, I repeat, my only [as I see it] rational choice is to plug-in my 
events into the standard loop. Under, say, plain wxPython, I can write 
my own, and call ProcessPendingEvents(), but with Matplotlib, no idea.
Ben Root  suggested to look some existing codes, say the Picker. But 
this is called upon a physical event, which is fired under the hood. 
My events are virtual, I have to post them myself from a callback, so 
it canot call recursively another callback, or I am dead.

Best regards.

Jerzy


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Events

2012-01-27 Thread Benjamin Root
On Fri, Jan 27, 2012 at 4:54 AM, Jerzy Karczmarczuk 
jerzy.karczmarc...@unicaen.fr wrote:

 Benjamin Root answers my query concerning user-generated events :
  To answer your question, take a look at how pick_event() is declared
  in backend_bases.py:
 
  def pick_event(self, mouseevent, artist, **kwargs):
   ...
  self.callbacks.process(s, event)
 
  The function that fires the event is self.callbacks.process(s,
  event), where self is the figure canvas.
 Dear Ben, thank you, but this is not exactly my problem. I don't want to
 call the callback myself, since the event should be fired from within
 a callback. I should have been more precise. Let's distil the problem.
 [This is a part of my current teaching...] I did already what you
 suggest here...

 Imagine an animation, which consists in generating a trajectory, segment
 after segment (say, of a planet). Classically this is a loop, but when
 it runs, the rest of the program is blocked. So, instead, the code
 behaves as a Python generator, generates just one segment, and that's
 all. But it yields something, it posts an event, put it in a queue,
 and somebody else, the mainloop() or similar, pops it off the queue and
 re-launches the callback. (With generators, it calls the .next()). No
 timers, as in Timer or Funct animations...

 It must be decentralized, no recursive calls. My callback from time to
 time creates another planet, or destroys an existent, and there are
 simultaneous trajectories on the screen, several concurrent events in
 the queue. And the system should remain reactive, interpret buttons,
 sliders, etc.

 I know how to do this by hand, how to write my own event loop, declare a
 queue, and how to add to my private virtual event handling also the
 callbacks of mouse events. But this is an overkill, I  repeat the
 functionalities which are already there, the event queue in particular.

 I did it with wx. But Matplotlib protects the user from the concrete
 back-end, and I want to protect my students as well, so I look for a
 GUI-neutral solution.

 Thanks.

 Jerzy


Still not sure why my suggestion would not work:

http://matplotlib.sourceforge.net/api/cbook_api.html#matplotlib.cbook.CallbackRegistry

You can have things set up such that event being triggered can subsequently
trigger other events as well.  An event can even connect a new event as
well.  An example where I do this is when I want to hide a line while it is
clicked.  In the function that I connect to a button_press_event, I make
the artist invisible, and I also create a lambda function that sets the
visibility of that artist to True (and subsequently disconnects itself) and
connect that lambda to a button_release_event.

Keep in mind that these events are merely key'ed by strings like
button_press_event, there is nothing magical about them.  So, when you
call the .process() function with a string value and an Event object, it
passes that object to every connection that was made with that same string
value.  You can call the process() function from anywhere, even within an
event.

Now, I haven't tried connecting a generator function with a yield statement
before, so I don't know how well that would work, but I don't know why it
wouldn't.

Why exactly would the callback registry not work for you?

Ben Root
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Hardware rendering with tricontourf

2012-01-27 Thread Benjamin Root
On Fri, Jan 27, 2012 at 10:06 AM, Howard how...@renci.org wrote:

  On 1/27/12 3:39 AM, Ian Thomas wrote:

 On 26 January 2012 19:36, Howard how...@renci.org wrote:

  I'm rendering some images with about 3.5 million triangles into a
 512x512 png file using tricontourf. I'm running this in a virtual machine,
 and I'm pretty sure that there is no graphics rendering hardware being
 used. Is it possible, assuming the hardware was available, to make
 tricontourf use the rendering hardware?  Will that happen by default?


 You are correct, there is no graphics hardware rendering.  Rendering is
 controlled by the various matplotlib backends, and to my knowledge there
 are  no backends currently available that use hardware rendering.

 There has been some work done on an OpenGL backend, but I am not sure of
 the status of this.  The last time I checked it was pretty experimental.
 Perhaps someone involved with it can comment on its current status.

 Ian Thomas

 Ian

 Thanks very much for the reply. If it helps whoever is doing the OpenGL
 backend, I may be able to play with it a bit.


 Howard


That would be the Glumpy project.

http://code.google.com/p/glumpy/

As stated in an email response a while back, glumpy is intended to be a
testbed for developing the OpenGL backend for future inclusion into
matplotlib.

Cheers!
Ben Root
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users