Reputation: 19
I would like to write GNUPLOT commands in to a txt file using Fortran, I can do it for most of the simple commands, but I have problem writing commands that contain special characters or AWK commands.
Assume I have a three column input file. First column is used to set the color of the points that their coordinates are stored in column 2 and 3.
For example, my input file called "Input.dat" is as follows:
blue 1 1
red 2 1
red 3 0
blue 4 1
red 5 1
blue 6 1
I use the following txt file which contains GNUPLOTs commands and I use to plot my input file.
GNUPLOT.txt:
plot "< awk '{if($1 == \"blue\") print}' Input.dat" u 2:3 t "blue" w p pt 7, \
"< awk '{if($1 == \"red\") print}' Input.dat" u 2:3 t "red" w p pt 7
pause -1
I need to create this input txt file using Fortran commands but I can not! Would you please let me know how to create a txt file like GNUPLOT.txt using Fortran commands?
I have used following commands with no luck:
write( 'GNUPLOT.txt', * )'set pointsize 3'
write( 'GNUPLOT.txt', * )'plot "< awk '{if($1 == \"blue\") print}' Input.dat" u 2:3 t "blue" w p pt 7, \'
write( 'GNUPLOT.txt', * )'"< awk '{if($1 == \"red\") print}' Input.dat" u 2:3 t "red" w p pt 7'
write( 'GNUPLOT.txt', * )'pause -1'
Thanks in advance,
Upvotes: 2
Views: 414
Reputation: 60078
write( 11, * ) 'set pointsize 3'
write( 11, * ) 'plot "< awk ''{if($1 == \"blue\") print}'' Input.dat" u 2:3 t "blue" w p pt 7, \'
write( 11, * ) '"< awk ''{if($1 == \"red\") print}'' Input.dat" u 2:3 t "red" w p pt 7'
write( 11, * ) 'pause -1'
Inside the string you must double the character you use to delimit the string.
For example,
print *,''''
end
will print just '
.
Upvotes: 2