Search code examples
gnuplot

Saving time - Compiling c++ and plotting at the same time gnuplot


Hi in order to save time whene I execute the code I command this line :

g++ name.cpp && ./a.out 

where nome,cpp is the name of the file that contains the code. If I succesively I need to plot some data generated by the exucatable with Gnuplot there is a way to add in the previous line instead of writing:

gnuplot
plot "name2.dat" 

?


Solution

  • you can:

    g++ name.cpp && ./a.out && gnuplot -e "plot 'name2.dat'; pause -1"
    

    gnuplot exits when you hit return (see help pause for more options)

    if you want to start an interactive gnuplot session there is a dirty way I implemented.

    g++ name.cpp && ./a.out && gnuplot -e "plot 'name2.dat' -
    

    (pay attention to the final minus sign)