Making graphs using c++

AGD

AGD

Soldato
Joined
23 Nov 2007
Posts
5,048
What is the easiest way to make 2-d graphs using c++? - without having to save an output stream to a file and then open in a spreadsheet for example.

I basically want to be able to run my calculations and maybe plot at the same time or just plot a stored array of results or something like that. I've tried installing komplot but when I try and make it I get errors. I've heard gnuplot is good but don't know how to link to it with c++. Has anyone tried koolplot? I'd prefer to work with linux but if there's an easy solution in windows I'm happy to use that.

Thanks in advance.
 
Output your data to a plain text file, e.g.

#x y <-- hash = comment line in gnuplot
0 3.99
1 2.22
2 3.56

then just either load in gnuplot:

<terminal>gnuplot
<gnuplot>plot "data.txt"

or write the commands in a script and just invoke

gnuplot script.p

(I do it this way, and have my code make gnuplot script files automatically).

This obviously won't automatically plot in "real time" as it goes, but it's the most flexible method - you have your data in a simple format, which other programs can use (e.g. xmgrace etc).
 
Back
Top Bottom