From: Paul W. B. <pa...@pu...> - 2008-03-07 13:19:01
|
Hello, i am writing a program in C++ where I am implementing the stuff I developed my thesis about eye glass optics with Matlab/Octave. I tried a C++ interface to gnuplot, but as the interface is not very nice and as I did not find this feature there until now, I am trying the C++ PLPlot interface right now. I need to draw graphs like those: http://m21s26.vlinux.de/math/gsg.png The data does not fit in a regular grid, so there has to be a kind of triangulation or something similar. In Matlab I use the function griddata for this. The lines to draw this graphs in Matlab are following: lmin = min(min(Zi)); lmax = max(max(Zi)); levels=[lmin:min(.1,(lmax-lmin)/100):lmax]; [C,h] = contourf(Xi,Yi,Zi,levels,'LineStyle','none'); axis equal; colorbar; grid on; Is there a way to do this with PLPlot? And if there is, how? Is this possible with the plstream::fcont method? Does PLPlot implement some kind of triangulation or do I have to write this on my own? Another issue: Is there a way to draw "quiver" graphs like this one? http://m21s26.vlinux.de/math/achs.png (In this case I multiplied the arrow length of the points with the z value.) Thank you very, very much for any hints. And sorry for this quite general questions. Regards Paul Wellner Bou |
From: Hezekiah M. C. <hc...@at...> - 2008-03-07 14:44:52
|
On Fri, Mar 7, 2008 at 8:23 AM, Paul Wellner Bou <pa...@pu...> wrote: > Hello, > > i am writing a program in C++ where I am implementing the stuff I > developed my thesis about eye glass optics with Matlab/Octave. I tried a > C++ interface to gnuplot, but as the interface is not very nice and as I > did not find this feature there until now, I am trying the C++ PLPlot > interface right now. > > I need to draw graphs like those: http://m21s26.vlinux.de/math/gsg.png > > The data does not fit in a regular grid, so there has to be a kind of > triangulation or something similar. In Matlab I use the function > griddata for this. The lines to draw this graphs in Matlab are following: > > lmin = min(min(Zi)); > lmax = max(max(Zi)); > levels=[lmin:min(.1,(lmax-lmin)/100):lmax]; > [C,h] = contourf(Xi,Yi,Zi,levels,'LineStyle','none'); > axis equal; > colorbar; > grid on; > > Is there a way to do this with PLPlot? And if there is, how? Is this > possible with the plstream::fcont method? Does PLPlot implement some > kind of triangulation or do I have to write this on my own? Would plgriddata do what you need? http://plplot.sourceforge.net/docbook-manual/plplot-html-5.9.0/plgriddata.html PLplot comes with several gridding methods, and I have used it for a few simple tests. plshades (or multiple calls to plshade) can generate the actual plot. http://plplot.sourceforge.net/docbook-manual/plplot-html-5.9.0/plshades.html PLplot does not have a built-in function to draw a color bar. I have written a simple one in OCaml which can probably be translated to C/C++ without a lot of trouble: http://code.google.com/p/ocaml-plplot/source/browse/trunk/extras.ml - color_bar at line 77 uses color map 1 (continuous colors) and color_bar0 at line 137 uses color map 0 (indexed colors). The OCaml plplot functions follow the C functions pretty closely. This is an example of what a color_bar0 color bar looks like: http://www.atmos.umd.edu/~hcarty/precip_maps/August/trmm_august_climatology.png color_bar would be similar. > Another issue: Is there a way to draw "quiver" graphs like this one? > http://m21s26.vlinux.de/math/achs.png > (In this case I multiplied the arrow length of the points with the z value.) I think plvect will do what you want here. http://plplot.sourceforge.net/docbook-manual/plplot-html-5.9.0/plvect.html plsvect can change the arrow style, and will hopefully give you what you want. I am new to PLplot as well, so these may not be the best methods available. They should help with what you need though. Hez -- Hezekiah M. Carty Graduate Research Assistant University of Maryland Department of Atmospheric and Oceanic Science |
From: Paul W. B. <pa...@pu...> - 2008-03-10 07:26:21
|
Hi, Thanks very, very much for your answer. > Would plgriddata do what you need? > http://plplot.sourceforge.net/docbook-manual/plplot-html-5.9.0/plgriddata.html Yes, I think thats exactly what I want. The "Delaunay Triangulation Linear Interpolation" method should do a fine job for my case. But I'll try the cubic spline method, too. > plshades (or multiple calls to plshade) can generate the actual plot. > http://plplot.sourceforge.net/docbook-manual/plplot-html-5.9.0/plshades.html Thank you. I'll have a closer look at plshade this weekend to understand what this is really doing. > PLplot does not have a built-in function to draw a color bar. I have > written a simple one in OCaml which can probably be translated to > C/C++ without a lot of trouble: No problem. color bar is not the most important thing. Could be drawn otherwise, too. But thanks for the suggestion. > I think plvect will do what you want here. > http://plplot.sourceforge.net/docbook-manual/plplot-html-5.9.0/plvect.html > plsvect can change the arrow style, and will hopefully give you what you want. Great. Looks like what I want. I'll try it and report. Thank you very much. Paul. |
From: Alan W. I. <ir...@be...> - 2008-03-07 15:13:32
|
On 2008-03-07 14:23+0100 Paul Wellner Bou wrote: > Hello, > > i am writing a program in C++ where I am implementing the stuff I > developed my thesis about eye glass optics with Matlab/Octave. I tried a > C++ interface to gnuplot, but as the interface is not very nice and as I > did not find this feature there until now, I am trying the C++ PLPlot > interface right now. There is an octave interface to PLplot that is normally built as part of the PLplot build. This interface includes complete access to low-level PLplot commands (see the octave implementation of all the PLplot standard examples at bindings/octave/demos/x??c.m) as well as higher-level plotting functionality (see bindings/octave/demos/p*.m for a a number of examples of this functionality). Anyhow, I suggest you try the octave interface to PLplot since it does have enhanced capabilities, and you do seem to be quite familiar with Matlab/Octave. Alan __________________________ Alan W. Irwin Astronomical research affiliation with Department of Physics and Astronomy, University of Victoria (astrowww.phys.uvic.ca). Programming affiliations with the FreeEOS equation-of-state implementation for stellar interiors (freeeos.sf.net); PLplot scientific plotting software package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________ |
From: Paul W. B. <pa...@pu...> - 2008-03-10 07:49:27
|
Hello, Thank you for the answer. Yes, I thought about using octave for this. The problem is that I was not able to reproduce the Matlab graphs with octave, neither using gnuplot nor octplot nor plplot. And the final application has to be easily installable on windows machines, and I don't want to force them to install octave first. Regards Paul. |