Class: NumPlot::Plotter
- Inherits:
-
Object
- Object
- NumPlot::Plotter
- Defined in:
- lib/numplot.rb
Overview
The plotter class. To plot something, you need to create a Plotter object, set parameters to the object, add data sets to the object, and call #plot as in the example below.
Constant Summary
Instance Attribute Summary (collapse)
- - (Array) datasets readonly deprecated Deprecated.
Instance Method Summary (collapse)
-
- (self) add_dataset(dataset)
(also: #<<)
Add a dataset to the plotter.
-
- (Object) disable_enhanced_text_mode
Disable an enhanced text mode of gnuplot.
-
- (Object) enable_enhanced_text_mode
Enable an enhanced text mode of gnuplot.
-
- (Plotter) initialize(plot_command = "plot")
constructor
Create a new Plotter object.
-
- (void) output(fname)
Set output target.
-
- (Object) plot(arg = {})
Plot given datasets with given parameters.
-
- (self) set(key, *values)
Gnuplot “set” command.
-
- (self) unset(key, *values)
Gnuplot “unset” command.
-
- (self) x2label(label, opts = {})
Set x2label parameter.
-
- (self) x2range(range, *opts)
Set x2range parameter.
-
- (self) xlabel(label, opts = {})
Set xlabel parameter.
-
- (self) xrange(range, *opts)
Set xrange parameter.
-
- (self) y2label(label, opts = {})
Set y2label parameter.
-
- (self) y2range(range, *opts)
Set y2range parameter.
-
- (self) ylabel(label, opts = {})
Set ylabel parameter.
-
- (self) yrange(range, *opts)
Set yrange parameter.
-
- (self) zlabel(label, opts = {})
Set zlabel parameter.
-
- (self) zrange(range, *opts)
Set zrange parameter.
Methods included from Conversion
convert_color, convert_font, convert_range, escape_label, quote, quote_label, range_bound, range_pair
Constructor Details
- (Plotter) initialize(plot_command = "plot")
Create a new Plotter object. You can specifiy the plot command (plot/splot) by plot_command parameter.
254 255 256 257 258 |
# File 'lib/numplot.rb', line 254 def initialize(plot_command = "plot") @plot_command = plot_command @commands = [] @datasets = [] end |
Instance Attribute Details
- (Array) datasets (readonly)
An array of all data sets.
263 264 265 |
# File 'lib/numplot.rb', line 263 def datasets @datasets end |
Instance Method Details
- (self) add_dataset(dataset) Also known as: <<
Add a dataset to the plotter.
300 301 302 303 |
# File 'lib/numplot.rb', line 300 def add_dataset(dataset) @datasets << dataset self end |
- (Object) disable_enhanced_text_mode
Disable an enhanced text mode of gnuplot.
356 357 358 359 |
# File 'lib/numplot.rb', line 356 def disable_enhanced_text_mode @enhanced = false set("termoption", "noenhanced") end |
- (Object) enable_enhanced_text_mode
Enable an enhanced text mode of gnuplot.
350 351 352 353 |
# File 'lib/numplot.rb', line 350 def enable_enhanced_text_mode @enhanced = true set("termoption", "enhanced") end |
- (void) output(fname)
This method returns an undefined value.
Set output target. You can specify target file name.
396 397 398 399 400 401 402 |
# File 'lib/numplot.rb', line 396 def output(fname) if fname.nil? set("output") else set("output", "\"#{fname}\"") end end |
- (void) plot(opts = {}) - (void) plot(io)
Plot given datasets with given parameters.
432 433 434 435 436 437 438 439 440 441 442 443 |
# File 'lib/numplot.rb', line 432 def plot(arg={}) if Hash === arg Process.open(arg.fetch(:persist, true), arg.fetch(:waiting, true), arg.fetch(:gnuplot_command, "gnuplot")) do |pr| plot_to_io(pr) end else plot_to_io(arg) end end |
- (self) set(key, *values)
283 284 285 |
# File 'lib/numplot.rb', line 283 def set(key, *values) add_command("set #{key} #{values.join(' ')}") end |
- (self) unset(key, *values)
Gnuplot “unset” command.
293 294 295 |
# File 'lib/numplot.rb', line 293 def unset(key, *values) add_command("unset #{key} #{values.join(' ')}") end |
- (self) x2label(label, opts = {})
383 |
# File 'lib/numplot.rb', line 383 def x2label(*args); _label("x2label", *args); end |
- (self) x2range(range, *opts)
332 |
# File 'lib/numplot.rb', line 332 def x2range(*args); _range("x2range", *args); end |
- (self) xlabel(label, opts = {})
377 |
# File 'lib/numplot.rb', line 377 def xlabel(*args); _label("xlabel", *args); end |
- (self) xrange(range, *opts)
326 |
# File 'lib/numplot.rb', line 326 def xrange(*args); _range("xrange", *args); end |
- (self) y2label(label, opts = {})
385 |
# File 'lib/numplot.rb', line 385 def y2label(*args); _label("y2label", *args); end |
- (self) y2range(range, *opts)
334 |
# File 'lib/numplot.rb', line 334 def y2range(*args); _range("y2range", *args); end |
- (self) ylabel(label, opts = {})
379 |
# File 'lib/numplot.rb', line 379 def ylabel(*args); _label("ylabel", *args); end |
- (self) yrange(range, *opts)
328 |
# File 'lib/numplot.rb', line 328 def yrange(*args); _range("yrange", *args); end |
- (self) zlabel(label, opts = {})
381 |
# File 'lib/numplot.rb', line 381 def zlabel(*args); _label("zlabel", *args); end |
- (self) zrange(range, *opts)
330 |
# File 'lib/numplot.rb', line 330 def zrange(*args); _range("zrange", *args); end |