473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

gnuplot parameter interchange

Hello,
my c++ programm produces a variable number of ASCII files with variable file
names. These are to be plotted in with gnuplot. I use

system("gnuplot -persist my_gnuplot_script.gpl");

to open gnuplot, and "my_gnuplot_script.gpl" contains a list of files to be
plotted (e.g. plot "array13.dat", "array87.dat",...). However, each time the
program runs, different files are to be plotted, so I have to change the
file names in my gnuplot script manually each time. How can I hand over some
parameters to gnuplot? Or would it be the easiest way to modify my .gpl
script by my c++ program? If so, how do I do that?
Thanks in advance,
Bernhard Hidding

-------------------------
SuSE 9.1, g++ compiler
Jul 22 '05 #1
3 2527
Bernhard Hidding wrote:

Hello,
my c++ programm produces a variable number of ASCII files with variable file
names. These are to be plotted in with gnuplot. I use

system("gnuplot -persist my_gnuplot_script.gpl");

to open gnuplot, and "my_gnuplot_script.gpl" contains a list of files to be
plotted (e.g. plot "array13.dat", "array87.dat",...). However, each time the
program runs, different files are to be plotted, so I have to change the
file names in my gnuplot script manually each time. How can I hand over some
parameters to gnuplot? Or would it be the easiest way to modify my .gpl
script by my c++ program? If so, how do I do that?


What you pass to system() is a string. Of course you can use a string
variable also. And thus you have every freedom you want to come
up with that string.

#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main()
{
std::string CommandLine;
std::string FileName;

CommandLine = "gnuplot -persist ";

cout << "Which file to plot?\n";
cin >> FileName;

CommandLine += FileName;

cout << "Executing command: " << CommandLine << endl;
system( CommandLine.c_str() );
}

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #2
Thank you,
but that is not quite what I intend to do. Maybe I did not make myself clear
enough.
In this case it is not enough to be able to chose between different gnuplot
script files, but to generate a script file on the fly. Each time my program
runs, a different script file would be needed, because each time new ASCII
files with different names are being created which shall be plotted. My c++
program contains all the data that the gnuplot script file would need to
know. So, is it the easiest way to let my c++ program create the gnuplot
script file and write it to disk, and call it after that? Or is there a
convenient way to pass variables over to gnuplot?

Bernhard
Jul 22 '05 #3
Bernhard Hidding wrote:

Thank you,
but that is not quite what I intend to do. Maybe I did not make myself clear
enough.
In this case it is not enough to be able to chose between different gnuplot
script files, but to generate a script file on the fly.
open script file
write commands as text to script file
close script file

use system() to execute script file
Each time my program
runs, a different script file would be needed, because each time new ASCII
files with different names are being created which shall be plotted. My c++
program contains all the data that the gnuplot script file would need to
know. So, is it the easiest way to let my c++ program create the gnuplot
script file and write it to disk, and call it after that? Or is there a
convenient way to pass variables over to gnuplot?


C++ knows nothing about gnuplot. There may be some way to control gnuplot
through some interprocess mechanism.

The simplest thing is .... see above

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Rama Calaga | last post by:
Hi, I use both python and gnuplot a lot, but I am unable to find a way to embed gnuplot "window/canvas" into tkinter. BLT option in PMW is not so powerful and not so great, any suggestions ?? ...
3
by: Blues | last post by:
Hey, I have used two great models - Tkinter and Gnuplot.py - for a while. I can display an image on a Canvas widget using Tkinter and I can also generate a gnuplot from Python on the fly in a...
9
by: syd | last post by:
I don't even know where to begin. This is just bizarre. I just picked up the Gnuplot.py module (a light interface to gnuplot commands) and was messing around with it today. I've got a tiny...
6
by: Joseph Suprenant | last post by:
Hello all, I have a C++ program, it does some calculations on things and then prints out a file in the format in which GNUPLOT can use. So my question is how would i call GNUPLOT from my C++...
1
by: Nicola Kaiser | last post by:
Hi, I´m using Gnuplot via gnuplot.py and I´m looking for a way to get the plotting output (terminal set to png in my case) piped in a string instead of to stdout or a file. Is there any...
0
by: bwaha | last post by:
I've posted this question to comp.graphics.apps.gnuplot too but given that this python group may also comprise a lot of gnuplot users, and is far more active, I've posted this question here too. My...
0
by: Titi Anggono | last post by:
Hi all, I made 2 arrays, which are i and uzuy (both are float). And I want to plot the graph between those arrays. I followed from the manual ==================
2
by: Blah | last post by:
I'm trying to use the system() in a C++ program to execute gnuplot on a file of data on OSX and have the graph pop up but so far the only thing I've managed to do is get gnuplot to open. as I...
3
by: arslanburney | last post by:
Hello. Was trying to create a simple plotting function. Wasnt working however. If i write the same code without putting it inside a function it works. :S. Could some1 tell me the problem? Heres the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.