cOdEr
cOdEr

Reputation: 21

Plotting graph with gnuplot in Shell scripting

I have to plot a graph using gnuplot with the help of shell script. I have written this code but its not working. I want to plot the graph in a html file so that I can see that graph in browser.

 echo "set term canvas mousing size 500, 500
 set output "file_name.html"
 plot 'my_file.txt' with lines" | gnuplot

I have saved this file in .bash on the desktop. Now I wrote this in terminal but it didn't work

sh file_name.bash

Please someone help me out with this. I am totally stuck with this thing since yesterday. :-(

Upvotes: 2

Views: 8876

Answers (1)

dwalter
dwalter

Reputation: 7468

There are multiple errors,

  • you use double-quotes within the echo which will not work. change it to single-quotes
  • use semi-colon instead of a line break for multiple gnuplot commands

So resulting script should be something like this

echo "set term canvas mousing size 500, 500; set output 'file_name.html'; plot 'my_file.txt' with lines" | gnuplot

or

cat << __EOF | gnuplot
set term canvas mousing size 500, 500
set output "file_name.html"
plot 'my_file.txt' with lines
__EOF

Upvotes: 2

Related Questions