Class: GraphKit::GnuplotSetOptions

Inherits:
KitHash show all
Defined in:
lib/graphkit/gnuplot.rb

Constant Summary collapse

QUOTED =
[ "title", "output", "xlabel", "ylabel", "zlabel", "x2label", "y2label", "z2label"  ]
GNUPLOT_SETS =
%w[    dgrid3d
    angles            arrow             autoscale         bars
 bmargin           border            boxwidth          cbdata
 cbdtics           cblabel           cbmtics           cbrange
 cbtics            clabel            clip              cntrparam
 colorbox          contour           data              datafile 
 date_specifiers   decimalsign                  dummy    
 encoding          fit               fontpath          format
 function          grid              hidden3d          historysize
 isosamples        key               label             lmargin
 loadpath          locale            log               logscale
 macros            mapping           margin            missing
 mouse                     mx2tics           mxtics
 my2tics           mytics            mztics            object
    nosurface
 offsets           origin            output            palette
 parametric        pm3d              pointsize         polar
 print             rmargin           rrange            samples
 size              style             surface           table
 term              terminal          termoption        tics
 ticscale          ticslevel         time_specifiers   timefmt
 timestamp         title             tmargin           trange
 urange            view              vrange            x2data
 x2dtics           x2label           x2mtics           x2range
 x2tics            x2zeroaxis        xdata             xdtics
 xlabel            xmtics            xrange            xtics
 xyplane           xzeroaxis         y2data            y2dtics
 y2label           y2mtics           y2range           y2tics
 y2zeroaxis        ydata             ydtics            ylabel
 ymtics            yrange            ytics             yzeroaxis
 zdata             zdtics            zero              zeroaxis
 zlabel            zmtics            zrange            ztics
multiplot ].map{|s| s.to_sym}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from KitHash

from_hash, #inspect

Methods included from Kit

#check, #method_missing

Methods inherited from Hash

#modify

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Kit

Instance Attribute Details

#multiplot_followingObject

Returns the value of attribute multiplot_following.



91
92
93
# File 'lib/graphkit/gnuplot.rb', line 91

def multiplot_following
  @multiplot_following
end

Instance Method Details

#[]=(opt, val) ⇒ Object



140
141
142
143
# File 'lib/graphkit/gnuplot.rb', line 140

def []=(opt, val)
  raise "#{opt} is not a valid gnuplot set option" unless GNUPLOT_SETS.include? opt
  super
end

#apply(io) ⇒ Object



145
146
147
148
149
150
151
152
153
154
# File 'lib/graphkit/gnuplot.rb', line 145

def apply(io)
  io << "set term #{GNUPLOT_DEFAULT_TERM}\n" unless self[:term] or self.multiplot_following
  self.each do |var,val|
    next unless val
    next if self.multiplot_following and ["term", "output"].include? var.to_s
    next if var.to_s == "multiplot"
    apply_option(io, var, val)
    end
  apply_option(io, :multiplot, self[:multiplot]) if self[:multiplot]
end

#apply_option(io, var, val) ⇒ Object



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/graphkit/gnuplot.rb', line 156

def apply_option(io, var, val)
    if val == "unset"
        #eputs "Unsetting #{var}"
      io << "unset #{var}\n"
      return
    end
     if var.to_s == 'log_axis'
      var = 'log'
     end
    if val.kind_of? Array
      val.each do |vall|
         io << "set #{var} #{vall}\n" 
      end
    elsif QUOTED.include? var.to_s and not val =~ /^\s*'.*'/
      #ep "quoting #{var}: #{val}"
      io << "set #{var} '#{val}'\n" 
    else
      io << "set #{var} #{val}\n" 
    end
end