Skip to content

Instantly share code, notes, and snippets.

@astellon
Created January 24, 2019 07:31
Show Gist options
  • Save astellon/cd84538b826d9e86b52cd6b14cde2dd4 to your computer and use it in GitHub Desktop.
Save astellon/cd84538b826d9e86b52cd6b14cde2dd4 to your computer and use it in GitHub Desktop.
module Plot
gnuplot = Process.new(command: "gnuplot", input: Process::Redirect::Pipe, output: Process::Redirect::Inherit)
input = gnuplot.input
# file out
input << "set terminal png\n"
input << "set output \'sin.png\'\n"
# plot
input << "set xrange [-10:10]\n"
input << "set yrange [-1:1]\n"
input << "plot sin(x)\n"
#exit
input << "exit\n"
input.flush
input.close
gnuplot.wait
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment