Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outputting plot data to stdout #26

Open
maasha opened this issue Nov 13, 2013 · 0 comments
Open

Outputting plot data to stdout #26

maasha opened this issue Nov 13, 2013 · 0 comments

Comments

@maasha
Copy link
Contributor

maasha commented Nov 13, 2013

Hello

I would like this script to output nice ASCII formatted plot data via the 'dumb' terminal to STDOUT, but I can't find a way? In fact, it could also be nice to allow output of raw PNG, PS and PDF data to STDOUT.

#!/usr/bin/env ruby

require 'gnuplot'
require 'pp'

# options = {
#   terminal: "png",
#   title: "Title",
#   xlabel: "X-axis",
#   ylabel: "Y-axis",
#   data_out: "foo.png"
# }

options = {
  terminal: "dumb",
  title: "Title",
  xlabel: "X-axis",
  ylabel: "Y-axis"
}

x = [0, 1, 2, 3]
y = [4, 5, 6, 7]

Gnuplot.open do |gp|
  Gnuplot::Plot.new(gp) do |plot|
    plot.terminal options[:terminal]
    plot.title    options[:title]
    plot.xlabel   options[:xlabel]
    plot.ylabel   options[:ylabel]
    plot.output   options[:data_out] if options[:data_out]
    plot.output   options[:data_out] if options[:data_out]
    plot.logscale "y"                if options[:logscale_y]
    plot.xrange   "[#{x.min - 1}:#{x.max + 1}]"
    plot.style    "fill solid 0.5 border"
    plot.xtics    "out"
    plot.ytics    "out"

    plot.data << Gnuplot::DataSet.new([x, y]) do |ds|
      ds.with = "boxes"
      ds.notitle
    end
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant