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 |