Method: SPCore::Plotter#plot_1d

Defined in:
lib/spcore/util/plotter.rb

#plot_1d(titled_sequences) ⇒ Object

Plot a sequence of values.

Examples:

Plotter.new.plot_1d "somedata" => [0,2,3,6,3,-1]

Parameters:

  • titled_sequences (Hash)

    A hash that maps title strings to data sequences. The data itself is an array of values. In the plot, values will be mapped to their index in the sequence.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/spcore/util/plotter.rb', line 74

def plot_1d titled_sequences
  datasets = []
  titled_sequences.each do |title, sequence|
    indices = Array.new(sequence.size)
    sequence.each_index do |i|
      indices[i] = i
      #if plot_against_fraction
      #  indices[i] /= sequence.size.to_f
      #end
    end
    
    dataset = Gnuplot::DataSet.new( [indices, sequence] ){ |ds|
      ds.with = @linestyle
      ds.title = title
      ds.linewidth = @linewidth
    }
    datasets << dataset
  end
  
  plot_datasets datasets
end