comp.lang.ada
 help / color / mirror / Atom feed
From: Jerry <lanceboyle@qwest.net>
Subject: Re: An easy way to simple scientific plots (in Ada)?
Date: Thu, 27 Dec 2007 12:23:26 -0800 (PST)
Date: 2007-12-27T12:23:26-08:00	[thread overview]
Message-ID: <01688775-bb6d-4af8-b11d-127af010bef9@e23g2000prf.googlegroups.com> (raw)
In-Reply-To: 41bd2384-83a7-46ff-87e9-d726623633e9@s12g2000prg.googlegroups.com

On Dec 26, 11:37 am, 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
> --       x**2 + y**2 = 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.  I'm going to stay uninvolved with buttons,
> callbacks and dialogs.  Instead, I just like to compute and plot
> numeric
> values.  I 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.  Their plotting far exceeds my needs.  But
> 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)   := Long_Float(i);
    end loop;
    y := 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



  parent reply	other threads:[~2007-12-27 20:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-26 18:37 An easy way to simple scientific plots (in Ada)? JPWoodruff
2007-12-26 21:30 ` Jeffrey R. Carter
2007-12-26 22:49   ` Manuel Collado
2007-12-27  4:07   ` JPWoodruff
2007-12-27  9:10     ` Dmitry A. Kazakov
2007-12-27 18:19       ` JPWoodruff
2007-12-27 22:52     ` Jeffrey R. Carter
2007-12-27  2:15 ` Jeffrey Creem
2007-12-27 13:56 ` Vadim Godunko
2007-12-29 22:28   ` I. Levashew
2007-12-30 18:40     ` JPWoodruff
2007-12-27 20:23 ` Jerry [this message]
2007-12-28 19:53   ` JPWoodruff
2007-12-30 21:25     ` Jerry
2007-12-31  3:40       ` JPWoodruff
2007-12-31 10:02         ` Jerry
2008-01-01 20:58 ` Gautier
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox