Perl - Gnuplot Interface
am 05.09.2007 21:52:05 von edgrsprj
PERL - GNUPLOT INTERFACE
Posted by E.D.G. September 5, 2007
This report contains two questions for Perl and Gnuplot experts. The
questions are listed first and then repeated with details.
1. Are Perl and Gnuplot the two best programs to use for the following
application?
2. What are the best ways to get Perl and Gnuplot to exchange control
statements and data for plotting?
1. Are Perl and Gnuplot the two best programs to use for the following
application?
The goal is to develop a good combination of a programming language such as
Perl and a chart generation program such as Gnuplot. The Perl program could
generate data and then direct Gnuplot to plot them.
The chart that was generated would remain in the foreground window. When a
RIGHT ARROW key was pressed for example, the chart might scroll to the
right. The UP ARROW might cause the chart to zoom in etc.
With separate data generation and plotting routines people could use
programs written in other languages such as Basic and Fortran to generate
their own data and then use shared Gnuplot plotting routines such as world
map files in order to plot the data.
Are there other programs which are better suited for such an application?
2. What are the best ways to get Perl and Gnuplot to exchange control
statements and data for plotting?
The interface would have to be sufficiently flexible that it would work with
programs written in other languages besides Perl.
The following routine will likely be used. I tested it and it works.
A Gnuplot chart would be displayed in the computer monitor window. Running
in the background and controlled by certain keyboard keys, a Perl program
would tell Gnuplot what data to plot and when to plot them.
Specifically,
A Perl program would be started. And data that it generated would be stored
in a file such as Plot.dat. Perl would also store some startup instructions
in a Gnuplot control file such as Control.gnu and direct it to start
running.
The Gnuplot program would then go into a loop that would repeatedly run
Control.gnu using a "Reread" statement along with a routine that would
enable it to exit the loop if necessary. A "Pause 0.1" statement in the
loop would keep Gnuplot from using large amounts of CPU time.
When Perl's IsKeyPressed("RIGHT") command determined that the RIGHT ARROW
key had been pressed for example, Perl would store a new set of commands in
Control.gnu. And Gnuplot would execute them and generate a new plot the
next time it read that file.
After the new data were plotted the looping commands would be stored once
again in Control.gnu. And Gnuplot would wait for the next commands from the
Perl program.
As I stated earlier, this routine has been tested. And it work. Are there
other, better ways to have Perl and Gnuplot exchange control statements and
data?
Final note - Perl also has the ability to send and receive data from the
clipboard. And through the use of the SendKeys() command it can have
Windows print text etc. to programs such as Gnuplot as if the text were
being typed on the keyboard.
Re: Perl - Gnuplot Interface
am 05.09.2007 21:59:23 von Aaron Sherman
On Sep 5, 3:52 pm, "E.D.G." wrote:
> 1. Are Perl and Gnuplot the two best programs to use for the following
> application?
Yes and no. You describe an interactive application, and gnuplot isn't
really ideal when it comes to interactive use.
On the other hand, a sufficiently robust back-end that uses gnuplot
could work. It just requires more work than some approaches.
> 2. What are the best ways to get Perl and Gnuplot to exchange control
> statements and data for plotting?
Simple I/O. Open a pipe to gnuplot. Print commands. Read the resulting
file.
For more info and other tools that you might use, see:
http://www.ibm.com/developerworks/library/os-perlgdchart/ind ex.html
Re: Perl - Gnuplot Interface
am 05.09.2007 23:46:12 von Abigail
_
E.D.G. (edgrsprj@ix.netcom.com) wrote on VCXVIII September MCMXCIII in
:
:) PERL - GNUPLOT INTERFACE
:)
:) Posted by E.D.G. September 5, 2007
:)
:) This report contains two questions for Perl and Gnuplot experts. The
:) questions are listed first and then repeated with details.
:)
:) 1. Are Perl and Gnuplot the two best programs to use for the following
:) application?
:)
:) 2. What are the best ways to get Perl and Gnuplot to exchange control
:) statements and data for plotting?
:)
:)
:) 1. Are Perl and Gnuplot the two best programs to use for the following
:) application?
:)
:) The goal is to develop a good combination of a programming language such as
:) Perl and a chart generation program such as Gnuplot. The Perl program could
:) generate data and then direct Gnuplot to plot them.
:)
:) The chart that was generated would remain in the foreground window. When a
:) RIGHT ARROW key was pressed for example, the chart might scroll to the
:) right. The UP ARROW might cause the chart to zoom in etc.
:)
:) With separate data generation and plotting routines people could use
:) programs written in other languages such as Basic and Fortran to generate
:) their own data and then use shared Gnuplot plotting routines such as world
:) map files in order to plot the data.
:)
:) Are there other programs which are better suited for such an application?
Insufficient data.
Whether a general programming langage is suited (or best suited) for a
particilar application determines more on the people who have to program
(and maintain) the application then what the application needs to do.
Ask among Perl programmers, and you'll get a lot of positive responses.
Ask the same question among Java or Python programmers, and you'll get
a lot less positive answers.
If I were to program such a thing, I wouldn't bother asking myself whether
Perl and/or gnuplot would be the best tools for the job. I'd use Perl and
gnuplot because I know Perl well, and the only plotting program I know is
gnuplot.
:)
:)
:) 2. What are the best ways to get Perl and Gnuplot to exchange control
:) statements and data for plotting?
:)
:) The interface would have to be sufficiently flexible that it would work with
:) programs written in other languages besides Perl.
:)
:) The following routine will likely be used. I tested it and it works.
:)
:) A Gnuplot chart would be displayed in the computer monitor window. Running
:) in the background and controlled by certain keyboard keys, a Perl program
:) would tell Gnuplot what data to plot and when to plot them.
:)
:) Specifically,
:)
:) A Perl program would be started. And data that it generated would be stored
:) in a file such as Plot.dat. Perl would also store some startup instructions
:) in a Gnuplot control file such as Control.gnu and direct it to start
:) running.
:)
:) The Gnuplot program would then go into a loop that would repeatedly run
:) Control.gnu using a "Reread" statement along with a routine that would
:) enable it to exit the loop if necessary. A "Pause 0.1" statement in the
:) loop would keep Gnuplot from using large amounts of CPU time.
:)
:) When Perl's IsKeyPressed("RIGHT") command determined that the RIGHT ARROW
:) key had been pressed for example, Perl would store a new set of commands in
:) Control.gnu. And Gnuplot would execute them and generate a new plot the
:) next time it read that file.
:)
:) After the new data were plotted the looping commands would be stored once
:) again in Control.gnu. And Gnuplot would wait for the next commands from the
:) Perl program.
:)
:) As I stated earlier, this routine has been tested. And it work. Are there
:) other, better ways to have Perl and Gnuplot exchange control statements and
:) data?
If you have a method that works, why are you looking for a 'better' way?
Aparently, you're not satisfied with this method, but you don't tell us
in which aspect you want to see it improved. In other words, what does
"better" mean to *you*?
Personally, communication over a pipe between Perl and gnuplot has always
worked for my needs.
Abigail
--
CHECK {print "another "}
INIT {print "Perl " }
END {print "Hacker\n"}
BEGIN {print "Just " }
Re: Perl - Gnuplot Interface
am 06.09.2007 00:20:18 von smallpond
On Sep 5, 3:52 pm, "E.D.G." wrote:
> PERL - GNUPLOT INTERFACE
>
> Posted by E.D.G. September 5, 2007
>
> This report contains two questions for Perl and Gnuplot experts. The
> questions are listed first and then repeated with details.
>
> 1. Are Perl and Gnuplot the two best programs to use for the following
> application?
>
> 2. What are the best ways to get Perl and Gnuplot to exchange control
> statements and data for plotting?
>
> 1. Are Perl and Gnuplot the two best programs to use for the following
> application?
>
> The goal is to develop a good combination of a programming language such as
> Perl and a chart generation program such as Gnuplot. The Perl program could
> generate data and then direct Gnuplot to plot them.
>
> The chart that was generated would remain in the foreground window. When a
> RIGHT ARROW key was pressed for example, the chart might scroll to the
> right. The UP ARROW might cause the chart to zoom in etc.
>
> With separate data generation and plotting routines people could use
> programs written in other languages such as Basic and Fortran to generate
> their own data and then use shared Gnuplot plotting routines such as world
> map files in order to plot the data.
>
> Are there other programs which are better suited for such an application?
>
> 2. What are the best ways to get Perl and Gnuplot to exchange control
> statements and data for plotting?
>
> The interface would have to be sufficiently flexible that it would work with
> programs written in other languages besides Perl.
>
> The following routine will likely be used. I tested it and it works.
>
> A Gnuplot chart would be displayed in the computer monitor window. Running
> in the background and controlled by certain keyboard keys, a Perl program
> would tell Gnuplot what data to plot and when to plot them.
>
> Specifically,
>
> A Perl program would be started. And data that it generated would be stored
> in a file such as Plot.dat. Perl would also store some startup instructions
> in a Gnuplot control file such as Control.gnu and direct it to start
> running.
>
> The Gnuplot program would then go into a loop that would repeatedly run
> Control.gnu using a "Reread" statement along with a routine that would
> enable it to exit the loop if necessary. A "Pause 0.1" statement in the
> loop would keep Gnuplot from using large amounts of CPU time.
>
> When Perl's IsKeyPressed("RIGHT") command determined that the RIGHT ARROW
> key had been pressed for example, Perl would store a new set of commands in
> Control.gnu. And Gnuplot would execute them and generate a new plot the
> next time it read that file.
>
> After the new data were plotted the looping commands would be stored once
> again in Control.gnu. And Gnuplot would wait for the next commands from the
> Perl program.
>
> As I stated earlier, this routine has been tested. And it work. Are there
> other, better ways to have Perl and Gnuplot exchange control statements and
> data?
>
> Final note - Perl also has the ability to send and receive data from the
> clipboard. And through the use of the SendKeys() command it can have
> Windows print text etc. to programs such as Gnuplot as if the text were
> being typed on the keyboard.
What is wrong with an all-perl solution like GD, GD::Graph, etc? I've
had pretty
good results with these for charting.
Your program structure is wrong. Use perl/Tk to draw the user
interface and process
events instead of having a wait loop. In your example, the right
arrow keypress
would be bound to a subroutine that would modify the arguments to the
chart
generation function. Make the user interface the master program.
Generate the
data to be plotted by passing the arguments to the Basic or FORTRAN
subprogram and
getting the data back through a file, named pipe, or socket interface
as desired.
Plot the result and display it in a Tk::Canvas. Have a button to save
it as a file.
-- S
Re: Perl - Gnuplot Interface
am 06.09.2007 14:38:14 von edgrsprj
"E.D.G." wrote in message
news:13du27dtkchf788@corp.supernews.com...
> PERL - GNUPLOT INTERFACE
Thanks to one and all for the responses.
Having considered the available information I am presently planning to go
with Perl (or Basic or Fortran etc. for other people) and Gnuplot. One of
the main reasons for choosing Gnuplot rather than one of the Perl chart
routines is because certain of the planned applications could be run
entirely with a standalone Gnuplot program plus a data file. In those cases
a separate programming language such as Perl would not be needed. The
following is one example:
Wave Charts
http://www.freewebz.com/eq-forecasting/130.html
For thousands of years people have been wondering why earthquakes occur at
the times when they occur. Various theories have proposed that earthquake
triggering times are linked with the gravitational pulls of the sun or the
moon, ocean tides etc. What I did was generate data for a number of those
variables and plotted them on the same time axis chart (Wave Chart). Using
the charts researchers can draw vertical lines on the days when earthquakes
of interest occurred and see which one of those variables might have been
involved with the triggering process.
The data file for the main Wave Chart is a number array with about 20
columns and 7500 rows. Presently a spreadsheet is used to generate the Wave
Charts. But Gnuplot should be able to manage that. Researchers around the
world would like to have such a program right now.
For future questions related specifically to Gnuplot I will probably just
post to that newsgroup. But since I am already posting this report I have
two Gnuplot questions.
1. If you have a number array that has 100 rows and 100 columns and you
wish to display only a 10 x 10 element subset at a time:
A. Should you plot all 100 x 100 elements and then try to scroll left and
right and up and down to see the area of interest?
B. Of, should you tell Gnuplot to plot the particular 10 x 10 element
subset of choice and change the starting row and column and replot the data
in order to scroll left and right and up and down?
Looking at the Gnuplot demos I formed the impression that B has to be used.
Choice A is not allowed.
2. Are there any already existing Gnuplot programs that use "bound" keys
such as RIGHT ARROW etc. and which allow you to work with large number
arrays and use data subsets to scroll left and right, up and down, zoom in
and out etc.?
I took another look at the Gnuplot Web site for information regarding
Question 2 but did not see much along those lines.
Comment - After running through the Gnuplot demos I have to say that the
plotting ability and speed of the program are impressive! And the program
itself does not appear to require too much RAM memory.