Skip to content

Outputting plot data to stdout #26

Description

@maasha

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions