From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b1a5713afb4e5c1 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!e23g2000prf.googlegroups.com!not-for-mail From: Jerry Newsgroups: comp.lang.ada Subject: Re: An easy way to simple scientific plots (in Ada)? Date: Thu, 27 Dec 2007 12:23:26 -0800 (PST) Organization: http://groups.google.com Message-ID: <01688775-bb6d-4af8-b11d-127af010bef9@e23g2000prf.googlegroups.com> References: <41bd2384-83a7-46ff-87e9-d726623633e9@s12g2000prg.googlegroups.com> NNTP-Posting-Host: 75.171.118.172 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1198787007 9149 127.0.0.1 (27 Dec 2007 20:23:27 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 27 Dec 2007 20:23:27 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e23g2000prf.googlegroups.com; posting-host=75.171.118.172; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/523.12.2 (KHTML, like Gecko) Version/3.0.4 Safari/523.12.2,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:19038 Date: 2007-12-27T12:23:26-08:00 List-Id: On Dec 26, 11:37=A0am, JPWoodr...@gmail.com wrote: > I'm an old Ada hobbyist who would like to plot some data from a > computation. What I want is scientific plots that are sort of the > opposite of industrial strength, in that small effort produces small > result but has no aspiration to scale. > > The kind of data I'll be examining are similar to > -- > type data is array (min..max) of float; > X, Y : data ; > -- > circle (X, Y : out data) ; > -- makes (max-min+1) values satisfying > -- =A0 =A0 =A0 x**2 + y**2 =3D 1; > plot_curve(X, Y) ; -- syntax to suit > -- puts a figure that's sort-of round into a window > > I've collected beaucoup graphics libraries over the years - (claw, > gwindows, jewl, win_io, windex, once upon a time a fairly immature > gtkada...) > > But I'm not a devotee of U-I programming so I've never committed much > thinking to any of these. =A0I'm going to stay uninvolved with buttons, > callbacks and dialogs. =A0Instead, I just like to compute and plot > numeric > values. =A0I wish I could do that in a context that didn't make me learn > all that stuff I'm not using. > > By way of comparison, I consider my need alongside the capabilities of > the R language environment. =A0Their plotting far exceeds my needs. =A0But= > the R language is a sad homely thing alongside Ada. > > So can I ask for a suggestion: which library would be simplest for me > to install and use for my task? > > Good fortune in the new year to all > John In my opinion, PLplot is exactly what you need. (I wrote the Ada bindings so my opinion may be biased 8^). PLplot is a fully-featured 2D and 3D plotting package with output suitable for publication. Output can go to any of a number of devices as well as to a variety of graphics files including Postscript. The development activity is very high the mailing list is very responsive. When I wrote the Ada bindings, I added a number of "simple plotters" for various plot types because I didn't want to have to do a bunch of set-up every time I wanted to make a plot--these "simple plotters" are not present in other bindings. But note that all of the PLplot functionality is available if you want to use it. Here is a very short example program that makes a plot: with Ada.Numerics.Long_Real_Arrays, PLplot, PLplot_Auxiliary; use Ada.Numerics.Long_Real_Arrays, PLplot, PLplot_Auxiliary; procedure simplest is x, y : Real_Vector(-10 .. 10); begin for i in x'range loop x(i) :=3D Long_Float(i); end loop; y :=3D x; Initialize_PLplot; Simple_Plot(x, y); -- One call to make the plot. End_PLplot; end simplest; Note that there are only an initialization and a finalization call as overhead. (These are standard and not part of my "simple plotters." After that, the plot is generated with only one call, as you specified. This particular "simple plotter" can contain a few more arguments so it is not quite as limited as one might think. For example, with suitably filled-out arrays, the plotter call might look like this: Simple_Plot(x, y1, y2, y3, y4, y5, "x label", "y label", "Page Title"); I should mention that the plotter is built for either Ada 2005 or non- Ada-2005 compilers. If your compiler is Ada 2005 (and thus Annex G.3 compliant, meaning that it has vector and matrix definitions), then it will recognize the type Real_Vector etc.; otherwise, that type is defined for you in the binding and your code will look the same. PLplot works without GUI programming. You can specify arguments to it when you call it such as output device, number of plots per page, etc. (not shown in the above example). I usually don't do that so when PLplot is initialized it will ask you at the command line to select your output device which requires just one keystroke plus Return. PLplot does not write data to disk in order to first plot it (like gnuplot) but uses your own data as it exists within the running program. This is a small matter but could make a speed difference on large data sets. Jerry