## Re: [Matplotlib-users] 3 axes plot, and histograms in 2D

 Re: [Matplotlib-users] 3 axes plot, and histograms in 2D From: Perry Greenfield - 2005-04-27 15:10:52 ```On Apr 27, 2005, at 9:58 AM, John Hunter wrote: > The plotting part for a 2D hist would be fairly easy (as a pcolor or > image). Is there no Nd histogram function in scipy or numarray? > Turns out that given a 1-d histogram function, it's pretty straightforward to write a reasonably efficient n-d function in Python using it in a few lines of code. I thought numarray had one (perhaps in the image stuff) but I'll have to check, scipy I thought did as well. Perry ```

 [Matplotlib-users] 3 axes plot, and histograms in 2D From: Eric Emsellem - 2005-04-27 06:56:47 ```Hi, I recently sent a mail to matplotlib-users regarding the availability of 3 axes plots and histograms in 2/N D and got no feedback. I understand this may not be a very exciting issue but if anybody has any input there (see below), it would be welcome. Thanks in advance!! cheers Eric ============================================= 3 axes plot ======== The more I am using matplotlib, the more I like it. But using it more means I more often hit the limits of the code, so I was wondering if there is any plan for a routine to plot data points w.r.t 3 axes (so a perspective scatter plot with x,y,z, data and a viewing angle). Of course another (maybe more difficult) goal would be to be able to draw surfaces, but already a simple scatter plot in 3D would help tremendously there (I realize the concept of "axis" has then to be revised, but well I have no idea how much effort this is). (if there is no - coming - plan for this, is there any way around it?) histograms ======== I would like to produce histograms in N dimensions, the minimum being in 2D. Here is an example of what I wish to do: I have a set of P particles with x and y positions. I have a rectangular grid, defined by e.g. a sampling in x and a sampling in y, (e.g. samp_x=arange(-15,31,1) ..), and I wish to know how many particles are in each "pixel". I can do that in many different ways (using searchsorted from numarray, or abruptly using loops, etc) but I am now looking for a simple (fewer lines) and efficient way (as I am treating large sets of particles) to do this so that I would be able to use a function like: histogram_2D(x,y, samp_x, samp_y) would return a matrix with the number of particles in each corresponding pixel. and showhistogram_2D(x,y, samp_x, samp_y) would display it [using e.g. imshow or matshow] Any hint there (I realize this is more a numarray question but I thought of first asking your community first since someone may have done it already)? And maybe also of how to generalize this in N dimensions? (for 1D matplotlib has the hist function..) -- =============================================================== Observatoire de Lyon emsellem@... 9 av. Charles-Andre tel: +33 4 78 86 83 84 69561 Saint-Genis Laval Cedex fax: +33 4 78 86 83 86 France http://www-obs.univ-lyon1.fr/eric.emsellem =============================================================== ```
 Re: [Matplotlib-users] 3 axes plot, and histograms in 2D From: John Hunter - 2005-04-27 13:58:34 ```>>>>> "Eric" == Eric Emsellem writes: Eric> Hi, I recently sent a mail to matplotlib-users regarding the Eric> availability of 3 axes plots and histograms in 2/N D and got Eric> no feedback. I understand this may not be a very exciting Eric> issue but if anybody has any input there (see below), it Eric> would be welcome. Thanks in advance!! I was out of the country and my mail server died, so I missed some messages... Eric> Eric ============================================= 3 axes Eric> plot ======== The more I am using matplotlib, the more I Eric> like it. But using it more means I more often hit the limits Eric> of the code, so I was wondering if there is any plan for a Eric> routine to plot data points w.r.t 3 axes (so a perspective Eric> scatter plot with x,y,z, data and a viewing angle). Of Eric> course another (maybe more difficult) goal would be to be Eric> able to draw surfaces, but already a simple scatter plot in Eric> 3D would help tremendously there (I realize the concept of Eric> "axis" has then to be revised, but well I have no idea how Eric> much effort this is). Eric> (if there is no - coming - plan for this, is there any way Eric> around it?) There is a lot of interest in this -- at least three of the developers besides me have expressed interest in working on this, so hopefully we can get something going. Maybe sometime this summer... Eric> Any hint there (I realize this is more a numarray question Eric> but I thought of first asking your community first since Eric> someone may have done it already)? And maybe also of how to Eric> generalize this in N dimensions? (for 1D matplotlib has the Eric> hist function..) The plotting part for a 2D hist would be fairly easy (as a pcolor or image). Is there no Nd histogram function in scipy or numarray? JDH ```
 Re: [Matplotlib-users] 3 axes plot, and histograms in 2D From: Perry Greenfield - 2005-04-27 15:10:52 ```On Apr 27, 2005, at 9:58 AM, John Hunter wrote: > The plotting part for a 2D hist would be fairly easy (as a pcolor or > image). Is there no Nd histogram function in scipy or numarray? > Turns out that given a 1-d histogram function, it's pretty straightforward to write a reasonably efficient n-d function in Python using it in a few lines of code. I thought numarray had one (perhaps in the image stuff) but I'll have to check, scipy I thought did as well. Perry ```
 Re: [Matplotlib-users] 3 axes plot, and histograms in 2D From: Perry Greenfield - 2005-04-27 14:00:00 ```Hi Eric, We've been talking about doing such things with John over the past few months but with no specific plans at the moment. I think the current fallback is to refer people to using VTK or one of the Python toolsets built on VTK for 3d plotting. Since VTK is such a big package we do understand the need for adding more basic 3d tools to matplotlib (though it naturally raises the question of where to draw the line; we don't want to re-implement VTK or any substantial fraction of it!). This includes surface and scatter plots (though I hadn't considered 2-d histograms--but these are essentially variants of surface plots). I'm not sure what you have in mind for higher dimensionality histograms. One of the questions to be answered is how we handle 3-d axes and their labeling. I doubt (John may differ on this) that we want to go into fancy 3-d character sets and such, but it may be possible to do simple transforms on fonts to make them look like they lay on the appropriate plane. On Apr 27, 2005, at 2:55 AM, Eric Emsellem wrote: > Hi, > I recently sent a mail to matplotlib-users regarding the availability > of 3 axes plots and histograms in 2/N D and got no feedback. > I understand this may not be a very exciting issue but if anybody has > any input there (see below), it would be welcome. Thanks in advance!! > > cheers > > Eric > ============================================= > 3 axes plot > ======== > The more I am using matplotlib, the more I like it. But using it more > means I more often hit the limits of the code, so I was wondering if > there is any plan for a routine to plot data points w.r.t 3 axes (so a > perspective scatter plot with x,y,z, data and a viewing angle). Of > course another (maybe more difficult) goal would be to be able to draw > surfaces, but already a simple scatter plot in 3D would help > tremendously there (I realize the concept of "axis" has then to be > revised, but well I have no idea how much effort this is). > > (if there is no - coming - plan for this, is there any way around it?) > > histograms > ======== > I would like to produce histograms in N dimensions, the minimum being > in 2D. > Here is an example of what I wish to do: > > I have a set of P particles with x and y positions. > I have a rectangular grid, defined by e.g. a sampling in x and a > sampling in y, (e.g. samp_x=arange(-15,31,1) ..), and I wish to know > how many particles are in each "pixel". > > I can do that in many different ways (using searchsorted from > numarray, or abruptly using loops, etc) but I am now looking for a > simple (fewer lines) and efficient way (as I am treating large sets of > particles) to do this so that I would be able to use a function like: > > histogram_2D(x,y, samp_x, samp_y) would return a matrix with the > number of particles in each corresponding pixel. > > and > > showhistogram_2D(x,y, samp_x, samp_y) would display it > [using e.g. imshow or matshow] > > Any hint there (I realize this is more a numarray question but I > thought of first asking your community first since someone may have > done it already)? And maybe also of how to generalize this in N > dimensions? (for 1D matplotlib has the hist function..) > ```
 Re: [Matplotlib-users] 3 axes plot, and histograms in 2D From: John Hunter - 2005-04-27 16:44:43 ```>>>>> "Perry" == Perry Greenfield writes: Perry> One of the questions to be answered is how we handle 3-d Perry> axes and their labeling. I doubt (John may differ on this) Perry> that we want to go into fancy 3-d character sets and such, Perry> but it may be possible to do simple transforms on fonts to Perry> make them look like they lay on the appropriate plane. Now that we can get the glyph vertices from agg/freetype, transforming them with a 4x4 matrix should be easy enough..... We've spent a lot of time talking about how to implement 3D (vtk, opengl, do the work ourselves in software and render it in 2D) but I am beginning to think this is the wrong discussion. We should just provide the front-end infrastructure which holds the data and transformations (Axes3D, Line3D, Poly3D, etc) and then let different 3D engines/backends handle the rendering, just as we do for 2D. Of course, one nuance is that the 3D renderer must render into the canvas which may also have 2D stuff in it, but I think this could be done via a bitmap transfer as Randy did for his proof-of-concept VTK/Agg demo, with an acceptable performance cost for most uses. The basic idea is that I don't think we need to commit to a 3D engine, we just need to set up the frontend API correctly. We should probably write up a semi-official pep for discussion, just to make sure the ideas are solid. Andrew has started on such a beast but has yet to let anyone see it :-) One open question is do we define new primitive types (Line3D, Poly3D, Text3D)? Doing so has the advantage of leaving the tried and true 2D stuff alone and does not impose extra memory or performance costs on the 2D side. But it creates multiple points of maintenance, etc... Another question: would it suffice to simply add a few new methods to the backend renderer, draw_line3d to complement draw_line, draw_polygon3d to complement draw_polygon, and so on. One might be able to then create mixin renderers, composing agg with say pyopengl to provide the 2D and 3D rendering respectively. Somehow this seems too easy, so it must be a stupid idea. JDH ```