Method: NumPlot::Plotter#plot

Defined in:
lib/numplot.rb

#plot(opts = {}) ⇒ void #plot(io) ⇒ void

Plot given datasets with given parameters.

Overloads:

  • #plot(opts = {}) ⇒ void

    This method returns an undefined value.

    Open a gnuplot process and write commands and data to the process. You get the result of plotting on a window or an image file

    You can specify the following options:

    • :persist - Add -persist to gnuplot command. The default value is true.

    • :waiting - Wait a gnuplot process to be terminate. The default value is true. If this value is true and the diagram is drawed on a new window, the ruby program is stopped until the window is closed. On the other hand, if this value is false, the ruby program continue although the window remains opened.

    • :gnuplot_command - gnuplot command name.

    Parameters:

    • opts (defaults to: {})

      options

  • #plot(io) ⇒ void

    This method returns an undefined value.

    Output all commands and data to IO object.

    Normally, you specify NumPlot::Process object as io. For debug use, you can specify the StringIO object as io.

    Parameters:

    • io (#write, #puts)

      output target



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