From: <seb...@sp...> - 2004-11-10 18:06:11
|
The examples on the screenshots page are great and very helpful. I hope to never use any other plotting app again except Matplotlib. What is easiest/cleanest way to modify examples to accept precalculated /data/ rather than use a mathematical /function/??? e.g. x = arange(xmin, xmax, dx) y = arange(ymin, ymax, dy) X,Y = meshgrid(x, y) Z = my_function(X, Y) im = imshow(Z, extent=(xmin, xmax, ymin, ymax)) How supply "Z" data myself rather than define my_function for Z? ==================== Also, plot(t, my_function(t)) Same question here for this 2D plot. (I have the 2D data already calculated.) thanks! Chris -- _______________________________________ Christian Seberino, Ph.D. SPAWAR Systems Center San Diego Code 2872 49258 Mills Street, Room 158 San Diego, CA 92152-5385 U.S.A. Phone: (619) 553-9973 Fax : (619) 553-6521 Email: seb...@sp... _______________________________________ |
From: Stephen W. <ste...@cs...> - 2004-11-10 20:22:39
|
On Wed, 2004-11-10 at 10:06 -0800, seb...@sp... wrote: > The examples on the screenshots page are great and very helpful. > I hope to never use any other plotting app again except Matplotlib. > > What is easiest/cleanest way to modify examples to accept > precalculated /data/ rather than use a mathematical /function/??? You have asked a _huge_ question. What format are these data in? ASCII files? HDF files? FITS images? JPEG images? -- Stephen Walton, Professor of Physics and Astronomy, California State University, Northridge ste...@cs... |
From: <seb...@sp...> - 2004-11-10 21:04:24
|
Stephen Thanks for the help. The format of the data is ASCII files and/or Python arrays that contain (x, y) coordinates or (x, y, z) coordinates for 3D. For starters, what is best way to plot triples in this list?... [ (0, 0, 3.3), (0, 1, 4.4), (1, 0, 2.2), (1, 1, 2.34)] I want to duplicate color plot on screenshots page: http://matplotlib.sourceforge.net/screenshots/pcolor_demo_large.png Chris On Wed, Nov 10, 2004 at 12:21:00PM -0800, Stephen Walton wrote: > On Wed, 2004-11-10 at 10:06 -0800, seb...@sp... wrote: > > The examples on the screenshots page are great and very helpful. > > I hope to never use any other plotting app again except Matplotlib. > > > > What is easiest/cleanest way to modify examples to accept > > precalculated /data/ rather than use a mathematical /function/??? > > You have asked a _huge_ question. What format are these data in? ASCII > files? HDF files? FITS images? JPEG images? > > -- > Stephen Walton, Professor of Physics and Astronomy, > California State University, Northridge > ste...@cs... > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Sybase ASE Linux Express Edition - download now for FREE > LinuxWorld Reader's Choice Award Winner for best database on Linux. > http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- _______________________________________ Christian Seberino, Ph.D. SPAWAR Systems Center San Diego Code 2872 49258 Mills Street, Room 158 San Diego, CA 92152-5385 U.S.A. Phone: (619) 553-9973 Fax : (619) 553-6521 Email: seb...@sp... _______________________________________ |
From: John H. <jdh...@ac...> - 2004-11-10 22:26:29
|
>>>>> "seberino" == seberino <seb...@sp...> writes: seberino> Stephen Thanks for the help. The format of the data is seberino> ASCII files and/or Python arrays that contain (x, y) seberino> coordinates or (x, y, z) coordinates for 3D. seberino> For starters, what is best way to plot triples in this seberino> list?... seberino> [ (0, 0, 3.3), (0, 1, 4.4), (1, 0, 2.2), (1, 1, 2.34)] seberino> I want to duplicate color plot on screenshots page: seberino> http://matplotlib.sourceforge.net/screenshots/pcolor_demo_large.png You have a 2x2 grid. pcolor is a bit funny in that for an MxN grid it only plots M-1 x N-1 rectangles since it doesn't know how to handle the edges. So it's a bit of a pathalogical case for pcolor. Basically you need to transform your list of 3 tuples into 3 arrays x,y,z, and then reshape the array. Here I'll use imshow which doesn't have the edge problem from matplotlib.matlab import * data = [ (0, 0, 3.3), (0, 1, 4.4), (1, 0, 2.2), (1, 1, 2.34)] x,y,z = zip(*data) z = array(z); z.shape = 2,2 imshow(z, interpolation='nearest', extent=(0,1,0,1)) show() If you had a longer data sequence, say 5x5, you would use pcolor like from matplotlib.matlab import * data = .... x,y,z = zip(*data) x = array(x); x.shape = 5,5 y = array(y); y.shape = 5,5 z = array(z); z.shape = 5,5 pcolor(x,y,z) show() In short, there is nothing special about plotting "data" versus "functions". Both are simply cases of plotting 1-D or 2-D arrays as far as matplotlib is concerned. Your task is to get your data in to the right array shape. JDH |