2

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. :-(

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

1 Comment

Why don't you simply use gnuplot << __EOF?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.