From 519ee3e17ae6d50009109dfdbda77bf21424cbee Mon Sep 17 00:00:00 2001 From: David Padilla Date: Mon, 12 Aug 2013 14:55:52 -0700 Subject: [PATCH 01/10] Get rid of Jeweler --- Gemfile | 3 +++ Gemfile.lock | 16 ++++++++++++++++ Rakefile | 13 +++---------- gnuplot.gemspec | 14 ++++++++++++++ lib/gnuplot/version.rb | 3 +++ 5 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 gnuplot.gemspec create mode 100644 lib/gnuplot/version.rb diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..c80ee36 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source "http://rubygems.org" + +gemspec diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..df32583 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,16 @@ +PATH + remote: . + specs: + gnuplot (2.6.1) + +GEM + remote: http://rubygems.org/ + specs: + rake (10.1.0) + +PLATFORMS + ruby + +DEPENDENCIES + gnuplot! + rake diff --git a/Rakefile b/Rakefile index 850c6d3..ed7c972 100644 --- a/Rakefile +++ b/Rakefile @@ -1,12 +1,5 @@ -require 'jeweler2' -Jeweler::Tasks.new do |s| - s.name = 'gnuplot' - s.description = s.summary = "Utility library to aid in interacting with gnuplot from ruby" - s.version = "2.6.1" - s.authors='roger pack' - s.email = "rogerpack2005@gmail.com" - s.homepage = "http://github.com/rdp/ruby_gnuplot/tree/master" -end +require 'bundler' +Bundler::GemHelper.install_tasks desc 'run unit tests' task :test do @@ -16,4 +9,4 @@ task :test do end end -Jeweler::RubygemsDotOrgTasks.new \ No newline at end of file +task :default => :test diff --git a/gnuplot.gemspec b/gnuplot.gemspec new file mode 100644 index 0000000..3b0d71f --- /dev/null +++ b/gnuplot.gemspec @@ -0,0 +1,14 @@ +# -*- encoding: utf-8 -*- +$:.push File.expand_path("../lib", __FILE__) +require "gnuplot/version" + +Gem::Specification.new do |s| + s.name = 'gnuplot' + s.description = s.summary = "Utility library to aid in interacting with gnuplot from ruby" + s.version = Gnuplot::VERSION + s.authors = 'roger pack' + s.email = "rogerpack2005@gmail.com" + s.homepage = "http://github.com/rdp/ruby_gnuplot/tree/master" + + s.add_development_dependency 'rake' +end diff --git a/lib/gnuplot/version.rb b/lib/gnuplot/version.rb new file mode 100644 index 0000000..8ad123b --- /dev/null +++ b/lib/gnuplot/version.rb @@ -0,0 +1,3 @@ +module Gnuplot + VERSION = "2.6.1" +end From 696564de7beb79e1473fb94809a4c59c4aea73e4 Mon Sep 17 00:00:00 2001 From: David Padilla Date: Mon, 12 Aug 2013 14:59:07 -0700 Subject: [PATCH 02/10] Extract Gnuplot::Plot to its own file --- lib/gnuplot.rb | 214 +++++++------------------------------------- lib/gnuplot/plot.rb | 154 +++++++++++++++++++++++++++++++ 2 files changed, 184 insertions(+), 184 deletions(-) create mode 100644 lib/gnuplot/plot.rb diff --git a/lib/gnuplot.rb b/lib/gnuplot.rb index f8faf42..fb635ae 100644 --- a/lib/gnuplot.rb +++ b/lib/gnuplot.rb @@ -1,21 +1,22 @@ # Methods and variables for interacting with the gnuplot process. Most of # these methods are for sending data to a gnuplot process, not for reading from -# it. Most of the methods are implemented as added methods to the built in +# it. Most of the methods are implemented as added methods to the built in # classes. require 'matrix' - +require 'gnuplot/plot' + module Gnuplot # Trivial implementation of the which command that uses the PATH environment # variable to attempt to find the given application. The application must # be executable and reside in one of the directories in the PATH environment # to be found. The first match that is found will be returned. - # + # # bin [String] The name of the executable to search for. - # + # # Return the full path to the first match or nil if no match is found. - # + # def Gnuplot.which ( bin ) if RUBY_PLATFORM =~ /mswin|mingw/ all = [bin, bin + '.exe'] @@ -41,18 +42,18 @@ def Gnuplot.which_helper bin # This is an implementation that works when the which command is # available. - # + # # IO.popen("which #{bin}") { |io| return io.readline.chomp } return nil - end + end # Find the path to the gnuplot executable. The name of the executable can # be specified using the RB_GNUPLOT environment variable but will default to - # the command 'gnuplot'. - # + # the command 'gnuplot'. + # # persist [bool] Add the persist flag to the gnuplot executable - # + # # Return the path to the gnuplot executable or nil if one cannot be found. def Gnuplot.gnuplot( persist = true ) exe_loc = which( ENV['RB_GNUPLOT'] || 'gnuplot' ) @@ -61,15 +62,15 @@ def Gnuplot.gnuplot( persist = true ) cmd += " -persist" if persist cmd end - + # Open a gnuplot process that exists in the current PATH. If the persist # flag is true then the -persist flag is added to the command line. The - # path to the gnuplot executable is determined using the 'which' command. + # path to the gnuplot executable is determined using the 'which' command. # # See the gnuplot documentation for information on the persist flag. # # todo Add a method to pass the gnuplot path to the function. - + def Gnuplot.open( persist=true ) cmd = Gnuplot.gnuplot( persist ) IO::popen( cmd, "w+") { |io| @@ -77,162 +78,7 @@ def Gnuplot.open( persist=true ) io.close_write @output = io.read } - return @output - end - - - - # Holds command information and performs the formatting of that command - # information to a Gnuplot process. When constructing a new plot for - # gnuplot, this is the first object that must be instantiated. On this - # object set the various properties and add data sets. - - class Plot - attr_accessor :cmd, :data, :settings - - QUOTED = [ "title", "output", "xlabel", "x2label", "ylabel", "y2label", "clabel", "cblabel", "zlabel" ] - - def initialize (io = nil, cmd = "plot") - @cmd = cmd - @settings = [] - @arbitrary_lines = [] - @data = [] - @styles = [] - yield self if block_given? - puts "writing this to gnuplot:\n" + to_gplot + "\n" if $VERBOSE - - if io - io << to_gplot - io << store_datasets - end - end - attr_accessor :arbitrary_lines - - # Invoke the set method on the plot using the name of the invoked method - # as the set variable and any arguments that have been passed as the - # value. See the +set+ method for more details. - - def method_missing( methId, *args ) - set methId.id2name, *args - end - - - # Set a variable to the given value. +Var+ must be a gnuplot variable and - # +value+ must be the value to set it to. Automatic quoting will be - # performed if the variable requires it. - # - # This is overloaded by the +method_missing+ method so see that for more - # readable code. - - def set ( var, value = "" ) - value = "\"#{value}\"" if QUOTED.include? var unless value =~ /^'.*'$/ - @settings << [ :set, var, value ] - end - - # Unset a variable. +Var+ must be a gnuplot variable. - def unset ( var ) - @settings << [ :unset, var ] - end - - - # Return the current value of the variable. This will return the setting - # that is currently in the instance, not one that's been given to a - # gnuplot process. - - def [] ( var ) - v = @settings.rassoc( var ) - if v.nil? or v.first == :unset - nil - else - v[2] - end - end - - class Style - attr_accessor :linestyle, :linetype, :linewidth, :linecolor, - :pointtype, :pointsize, :fill, :index - - alias :ls :linestyle - alias :lt :linetype - alias :lw :linewidth - alias :lc :linecolor - alias :pt :pointtype - alias :ps :pointsize - alias :fs :fill - - alias :ls= :linestyle= - alias :lt= :linetype= - alias :lw= :linewidth= - alias :lc= :linecolor= - alias :pt= :pointtype= - alias :ps= :pointsize= - alias :fs= :fill= - - STYLES = [:ls, :lt, :lw, :lc, :pt, :ps, :fs] - - def Style.increment_index - @index ||= 0 - @index += 1 - - @index - end - - def initialize - STYLES.each do |s| - send("#{s}=", nil) - end - yield self if block_given? - - # only set the index if the user didn't do it - @index = Style::increment_index if index.nil? - end - - def to_s - str = "set style line #{index}" - STYLES.each do |s| - style = send(s) - if not style.nil? - str << " #{s} #{style}" - end - end - - str - end - end - - # Create a gnuplot linestyle - def style &blk - s = Style.new &blk - @styles << s - s - end - - def add_data ( ds ) - @data << ds - end - - - def to_gplot (io = "") - @settings.each do |setting| - io << setting.map(&:to_s).join(" ") << "\n" - end - @styles.each{|s| io << s.to_s << "\n"} - @arbitrary_lines.each{|line| io << line << "\n" } - - io - end - - def store_datasets (io = "") - if @data.size > 0 - io << @cmd << " " << @data.collect { |e| e.plot_args }.join(", ") - io << "\n" - - v = @data.collect { |ds| ds.to_gplot } - io << v.compact.join("e\n") - end - - io - end + return @output end # Analogous to Plot class, holds command information and performs the formatting of that command @@ -243,7 +89,7 @@ class SPlot < Plot def initialize (io = nil, cmd = "splot") super end - + # Currently using the implementation from parent class Plot. # Leaving the method explicit here, though, as to allow an specific # implementation for SPlot in the future. @@ -258,7 +104,7 @@ def to_gplot (io = "") # has a reference to the actual data being plotted as well as settings that # control the "plot" command. The data object must support the to_gplot # command. - # + # # +data+ The data that will be plotted. The only requirement is that the # object understands the to_gplot method. # @@ -269,25 +115,25 @@ def to_gplot (io = "") # # @todo Use the delegator to delegate to the data property. - class DataSet + class DataSet attr_accessor :title, :with, :using, :data, :linewidth, :linecolor, :matrix, :smooth, :axes, :index, :linestyle alias :ls :linestyle alias :ls= :linestyle= - + def initialize (data = nil) @data = data @linestyle = @title = @with = @using = @linewidth = @linecolor = @matrix = @smooth = @axes = @index = nil # avoid warnings yield self if block_given? end - + def notitle @title = "notitle" end def plot_args (io = "") - + # Order of these is important or gnuplot barfs on 'em io << ( (@data.instance_of? String) ? @data : "'-'" ) @@ -295,13 +141,13 @@ def plot_args (io = "") io << " index #{@index}" if @index io << " using #{@using}" if @using - + io << " axes #{@axes}" if @axes - + io << case @title when /notitle/ then " notitle" when nil then "" - else " title '#{@title}'" + else " title '#{@title}'" end io << " matrix" if @matrix @@ -328,7 +174,7 @@ def to_gsplot else @data.to_gsplot end end - + end end @@ -348,7 +194,7 @@ def to_gplot def to_gsplot f = "" - + if ( self[0].kind_of? Array ) then x = self[0] y = self[1] @@ -365,16 +211,16 @@ def to_gsplot else self[0].zip( *self[1..-1] ).to_gsplot end - + f end end - + class Matrix def to_gplot (x = nil, y = nil) xgrid = x || (0...self.column_size).to_a ygrid = y || (0...self.row_size).to_a - + f = "" ygrid.length.times do |j| y = ygrid[j] @@ -384,7 +230,7 @@ def to_gplot (x = nil, y = nil) end end end - + f end diff --git a/lib/gnuplot/plot.rb b/lib/gnuplot/plot.rb new file mode 100644 index 0000000..296c14f --- /dev/null +++ b/lib/gnuplot/plot.rb @@ -0,0 +1,154 @@ +module Gnuplot + # Holds command information and performs the formatting of that command + # information to a Gnuplot process. When constructing a new plot for + # gnuplot, this is the first object that must be instantiated. On this + # object set the various properties and add data sets. + + class Plot + attr_accessor :cmd, :data, :settings + + QUOTED = [ "title", "output", "xlabel", "x2label", "ylabel", "y2label", "clabel", "cblabel", "zlabel" ] + + def initialize (io = nil, cmd = "plot") + @cmd = cmd + @settings = [] + @arbitrary_lines = [] + @data = [] + @styles = [] + yield self if block_given? + puts "writing this to gnuplot:\n" + to_gplot + "\n" if $VERBOSE + + if io + io << to_gplot + io << store_datasets + end + end + attr_accessor :arbitrary_lines + + # Invoke the set method on the plot using the name of the invoked method + # as the set variable and any arguments that have been passed as the + # value. See the +set+ method for more details. + + def method_missing( methId, *args ) + set methId.id2name, *args + end + + + # Set a variable to the given value. +Var+ must be a gnuplot variable and + # +value+ must be the value to set it to. Automatic quoting will be + # performed if the variable requires it. + # + # This is overloaded by the +method_missing+ method so see that for more + # readable code. + + def set ( var, value = "" ) + value = "\"#{value}\"" if QUOTED.include? var unless value =~ /^'.*'$/ + @settings << [ :set, var, value ] + end + + # Unset a variable. +Var+ must be a gnuplot variable. + def unset ( var ) + @settings << [ :unset, var ] + end + + + # Return the current value of the variable. This will return the setting + # that is currently in the instance, not one that's been given to a + # gnuplot process. + + def [] ( var ) + v = @settings.rassoc( var ) + if v.nil? or v.first == :unset + nil + else + v[2] + end + end + + class Style + attr_accessor :linestyle, :linetype, :linewidth, :linecolor, + :pointtype, :pointsize, :fill, :index + + alias :ls :linestyle + alias :lt :linetype + alias :lw :linewidth + alias :lc :linecolor + alias :pt :pointtype + alias :ps :pointsize + alias :fs :fill + + alias :ls= :linestyle= + alias :lt= :linetype= + alias :lw= :linewidth= + alias :lc= :linecolor= + alias :pt= :pointtype= + alias :ps= :pointsize= + alias :fs= :fill= + + STYLES = [:ls, :lt, :lw, :lc, :pt, :ps, :fs] + + def Style.increment_index + @index ||= 0 + @index += 1 + + @index + end + + def initialize + STYLES.each do |s| + send("#{s}=", nil) + end + yield self if block_given? + + # only set the index if the user didn't do it + @index = Style::increment_index if index.nil? + end + + def to_s + str = "set style line #{index}" + STYLES.each do |s| + style = send(s) + if not style.nil? + str << " #{s} #{style}" + end + end + + str + end + end + + # Create a gnuplot linestyle + def style &blk + s = Style.new &blk + @styles << s + s + end + + def add_data ( ds ) + @data << ds + end + + + def to_gplot (io = "") + @settings.each do |setting| + io << setting.map(&:to_s).join(" ") << "\n" + end + @styles.each{|s| io << s.to_s << "\n"} + @arbitrary_lines.each{|line| io << line << "\n" } + + io + end + + def store_datasets (io = "") + if @data.size > 0 + io << @cmd << " " << @data.collect { |e| e.plot_args }.join(", ") + io << "\n" + + v = @data.collect { |ds| ds.to_gplot } + io << v.compact.join("e\n") + end + + io + end + end +end From a0f28e4674b69fa5b8900bb44b01f28be7609c36 Mon Sep 17 00:00:00 2001 From: David Padilla Date: Mon, 12 Aug 2013 15:00:39 -0700 Subject: [PATCH 03/10] Extract Gnuplot::Splot to separate file --- lib/gnuplot.rb | 20 +------------------- lib/gnuplot/splot.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 19 deletions(-) create mode 100644 lib/gnuplot/splot.rb diff --git a/lib/gnuplot.rb b/lib/gnuplot.rb index fb635ae..fd403ef 100644 --- a/lib/gnuplot.rb +++ b/lib/gnuplot.rb @@ -5,6 +5,7 @@ require 'matrix' require 'gnuplot/plot' +require 'gnuplot/splot' module Gnuplot @@ -81,25 +82,6 @@ def Gnuplot.open( persist=true ) return @output end - # Analogous to Plot class, holds command information and performs the formatting of that command - # information to a Gnuplot process. Should be used when for drawing 3D plots. - - class SPlot < Plot - - def initialize (io = nil, cmd = "splot") - super - end - - # Currently using the implementation from parent class Plot. - # Leaving the method explicit here, though, as to allow an specific - # implementation for SPlot in the future. - def to_gplot (io = "") - super - end - - end - - # Container for a single dataset being displayed by gnuplot. Each object # has a reference to the actual data being plotted as well as settings that # control the "plot" command. The data object must support the to_gplot diff --git a/lib/gnuplot/splot.rb b/lib/gnuplot/splot.rb new file mode 100644 index 0000000..5b0e411 --- /dev/null +++ b/lib/gnuplot/splot.rb @@ -0,0 +1,19 @@ +module Gnuplot + # Analogous to Plot class, holds command information and performs the formatting of that command + # information to a Gnuplot process. Should be used when for drawing 3D plots. + + class SPlot < Plot + + def initialize (io = nil, cmd = "splot") + super + end + + # Currently using the implementation from parent class Plot. + # Leaving the method explicit here, though, as to allow an specific + # implementation for SPlot in the future. + def to_gplot (io = "") + super + end + + end +end From ee6d6043dec2231e737aaf27e2fdb94d12638fed Mon Sep 17 00:00:00 2001 From: David Padilla Date: Mon, 12 Aug 2013 15:08:07 -0700 Subject: [PATCH 04/10] Extract Dataset, Array and Matrix to their own files --- lib/gnuplot.rb | 138 +---------------------------------------- lib/gnuplot/array.rb | 41 ++++++++++++ lib/gnuplot/dataset.rb | 77 +++++++++++++++++++++++ lib/gnuplot/matrix.rb | 23 +++++++ 4 files changed, 144 insertions(+), 135 deletions(-) create mode 100644 lib/gnuplot/array.rb create mode 100644 lib/gnuplot/dataset.rb create mode 100644 lib/gnuplot/matrix.rb diff --git a/lib/gnuplot.rb b/lib/gnuplot.rb index fd403ef..ddb4196 100644 --- a/lib/gnuplot.rb +++ b/lib/gnuplot.rb @@ -4,6 +4,9 @@ # classes. require 'matrix' +require 'gnuplot/array' +require 'gnuplot/matrix' +require 'gnuplot/dataset' require 'gnuplot/plot' require 'gnuplot/splot' @@ -81,139 +84,4 @@ def Gnuplot.open( persist=true ) } return @output end - - # Container for a single dataset being displayed by gnuplot. Each object - # has a reference to the actual data being plotted as well as settings that - # control the "plot" command. The data object must support the to_gplot - # command. - # - # +data+ The data that will be plotted. The only requirement is that the - # object understands the to_gplot method. - # - # The following attributes correspond to their related string in the gnuplot - # command. See the gnuplot documentation for more information on this. - # - # title, with - # - # @todo Use the delegator to delegate to the data property. - - class DataSet - attr_accessor :title, :with, :using, :data, :linewidth, :linecolor, :matrix, :smooth, :axes, :index, :linestyle - - alias :ls :linestyle - alias :ls= :linestyle= - - def initialize (data = nil) - @data = data - @linestyle = @title = @with = @using = @linewidth = @linecolor = @matrix = - @smooth = @axes = @index = nil # avoid warnings - yield self if block_given? - end - - def notitle - @title = "notitle" - end - - def plot_args (io = "") - - # Order of these is important or gnuplot barfs on 'em - - io << ( (@data.instance_of? String) ? @data : "'-'" ) - - io << " index #{@index}" if @index - - io << " using #{@using}" if @using - - io << " axes #{@axes}" if @axes - - io << case @title - when /notitle/ then " notitle" - when nil then "" - else " title '#{@title}'" - end - - io << " matrix" if @matrix - io << " smooth #{@smooth}" if @smooth - io << " with #{@with}" if @with - io << " linecolor #{@linecolor}" if @linecolor - io << " linewidth #{@linewidth}" if @linewidth - io << " linestyle #{@linestyle.index}" if @linestyle - io - end - - def to_gplot - case @data - when nil then nil - when String then nil - else @data.to_gplot - end - end - - def to_gsplot - case @data - when nil then nil - when String then nil - else @data.to_gsplot - end - end - - end -end - -class Array - def to_gplot - if ( self[0].kind_of? Array ) then - tmp = self[0].zip( *self[1..-1] ) - tmp.collect { |a| a.join(" ") }.join("\n") + "\ne" - elsif ( self[0].kind_of? Numeric ) then - s = "" - self.length.times { |i| s << "#{self[i]}\n" } - s - else - self[0].zip( *self[1..-1] ).to_gplot - end - end - - def to_gsplot - f = "" - - if ( self[0].kind_of? Array ) then - x = self[0] - y = self[1] - d = self[2] - - x.each_with_index do |xv, i| - y.each_with_index do |yv, j| - f << [ xv, yv, d[i][j] ].join(" ") << "\n" - end - # f << "\n" - end - elsif ( self[0].kind_of? Numeric ) then - self.length.times do |i| f << "#{self[i]}\n" end - else - self[0].zip( *self[1..-1] ).to_gsplot - end - - f - end -end - -class Matrix - def to_gplot (x = nil, y = nil) - xgrid = x || (0...self.column_size).to_a - ygrid = y || (0...self.row_size).to_a - - f = "" - ygrid.length.times do |j| - y = ygrid[j] - xgrid.length.times do |i| - if ( self[j,i] ) then - f << "#{xgrid[i]} #{y} #{self[j,i]}\n" - end - end - end - - f - end - end diff --git a/lib/gnuplot/array.rb b/lib/gnuplot/array.rb new file mode 100644 index 0000000..0b3d825 --- /dev/null +++ b/lib/gnuplot/array.rb @@ -0,0 +1,41 @@ +module Gnuplot + module Array + def to_gplot + if ( self[0].kind_of? Array ) then + tmp = self[0].zip( *self[1..-1] ) + tmp.collect { |a| a.join(" ") }.join("\n") + "\ne" + elsif ( self[0].kind_of? Numeric ) then + s = "" + self.length.times { |i| s << "#{self[i]}\n" } + s + else + self[0].zip( *self[1..-1] ).to_gplot + end + end + + def to_gsplot + f = "" + + if ( self[0].kind_of? Array ) then + x = self[0] + y = self[1] + d = self[2] + + x.each_with_index do |xv, i| + y.each_with_index do |yv, j| + f << [ xv, yv, d[i][j] ].join(" ") << "\n" + end + # f << "\n" + end + elsif ( self[0].kind_of? Numeric ) then + self.length.times do |i| f << "#{self[i]}\n" end + else + self[0].zip( *self[1..-1] ).to_gsplot + end + + f + end + end +end + +Array.send(:include, Gnuplot::Array) diff --git a/lib/gnuplot/dataset.rb b/lib/gnuplot/dataset.rb new file mode 100644 index 0000000..836fcc3 --- /dev/null +++ b/lib/gnuplot/dataset.rb @@ -0,0 +1,77 @@ +module Gnuplot + # Container for a single dataset being displayed by gnuplot. Each object + # has a reference to the actual data being plotted as well as settings that + # control the "plot" command. The data object must support the to_gplot + # command. + # + # +data+ The data that will be plotted. The only requirement is that the + # object understands the to_gplot method. + # + # The following attributes correspond to their related string in the gnuplot + # command. See the gnuplot documentation for more information on this. + # + # title, with + # + # @todo Use the delegator to delegate to the data property. + + class DataSet + attr_accessor :title, :with, :using, :data, :linewidth, :linecolor, :matrix, :smooth, :axes, :index, :linestyle + + alias :ls :linestyle + alias :ls= :linestyle= + + def initialize (data = nil) + @data = data + @linestyle = @title = @with = @using = @linewidth = @linecolor = @matrix = @smooth = @axes = @index = nil # avoid warnings + yield self if block_given? + end + + def notitle + @title = "notitle" + end + + def plot_args (io = "") + + # Order of these is important or gnuplot barfs on 'em + + io << ( (@data.instance_of? String) ? @data : "'-'" ) + + io << " index #{@index}" if @index + + io << " using #{@using}" if @using + + io << " axes #{@axes}" if @axes + + io << case @title + when /notitle/ then " notitle" + when nil then "" + else " title '#{@title}'" + end + + io << " matrix" if @matrix + io << " smooth #{@smooth}" if @smooth + io << " with #{@with}" if @with + io << " linecolor #{@linecolor}" if @linecolor + io << " linewidth #{@linewidth}" if @linewidth + io << " linestyle #{@linestyle.index}" if @linestyle + io + end + + def to_gplot + case @data + when nil then nil + when String then nil + else @data.to_gplot + end + end + + def to_gsplot + case @data + when nil then nil + when String then nil + else @data.to_gsplot + end + end + + end +end diff --git a/lib/gnuplot/matrix.rb b/lib/gnuplot/matrix.rb new file mode 100644 index 0000000..bd48e21 --- /dev/null +++ b/lib/gnuplot/matrix.rb @@ -0,0 +1,23 @@ +require 'matrix' + +module Gnuplot + module Matrix + def to_gplot (x = nil, y = nil) + xgrid = x || (0...self.column_size).to_a + ygrid = y || (0...self.row_size).to_a + + f = "" + ygrid.length.times do |j| + y = ygrid[j] + xgrid.length.times do |i| + if ( self[j,i] ) then + f << "#{xgrid[i]} #{y} #{self[j,i]}\n" + end + end + end + + f + end + + end +end From 282defaea03586e073554c491ae409f902cf9fae Mon Sep 17 00:00:00 2001 From: David Padilla Date: Mon, 12 Aug 2013 15:19:45 -0700 Subject: [PATCH 05/10] Reindent and clean the code --- lib/gnuplot/array.rb | 34 +++++++++++++++++----------------- lib/gnuplot/dataset.rb | 3 ++- lib/gnuplot/matrix.rb | 24 ++++++++++++------------ lib/gnuplot/plot.rb | 14 +++++++------- 4 files changed, 38 insertions(+), 37 deletions(-) diff --git a/lib/gnuplot/array.rb b/lib/gnuplot/array.rb index 0b3d825..7180ac6 100644 --- a/lib/gnuplot/array.rb +++ b/lib/gnuplot/array.rb @@ -2,14 +2,14 @@ module Gnuplot module Array def to_gplot if ( self[0].kind_of? Array ) then - tmp = self[0].zip( *self[1..-1] ) - tmp.collect { |a| a.join(" ") }.join("\n") + "\ne" + tmp = self[0].zip( *self[1..-1] ) + tmp.collect { |a| a.join(" ") }.join("\n") + "\ne" elsif ( self[0].kind_of? Numeric ) then - s = "" - self.length.times { |i| s << "#{self[i]}\n" } - s + s = "" + self.length.times { |i| s << "#{self[i]}\n" } + s else - self[0].zip( *self[1..-1] ).to_gplot + self[0].zip( *self[1..-1] ).to_gplot end end @@ -17,20 +17,20 @@ def to_gsplot f = "" if ( self[0].kind_of? Array ) then - x = self[0] - y = self[1] - d = self[2] + x = self[0] + y = self[1] + d = self[2] - x.each_with_index do |xv, i| - y.each_with_index do |yv, j| - f << [ xv, yv, d[i][j] ].join(" ") << "\n" - end - # f << "\n" - end + x.each_with_index do |xv, i| + y.each_with_index do |yv, j| + f << [ xv, yv, d[i][j] ].join(" ") << "\n" + end + # f << "\n" + end elsif ( self[0].kind_of? Numeric ) then - self.length.times do |i| f << "#{self[i]}\n" end + self.length.times do |i| f << "#{self[i]}\n" end else - self[0].zip( *self[1..-1] ).to_gsplot + self[0].zip( *self[1..-1] ).to_gsplot end f diff --git a/lib/gnuplot/dataset.rb b/lib/gnuplot/dataset.rb index 836fcc3..61eb063 100644 --- a/lib/gnuplot/dataset.rb +++ b/lib/gnuplot/dataset.rb @@ -22,7 +22,8 @@ class DataSet def initialize (data = nil) @data = data - @linestyle = @title = @with = @using = @linewidth = @linecolor = @matrix = @smooth = @axes = @index = nil # avoid warnings + @linestyle = @title = @with = @using = @linewidth = @linecolor = + @matrix = @smooth = @axes = @index = nil # avoid warnings yield self if block_given? end diff --git a/lib/gnuplot/matrix.rb b/lib/gnuplot/matrix.rb index bd48e21..ec148c2 100644 --- a/lib/gnuplot/matrix.rb +++ b/lib/gnuplot/matrix.rb @@ -3,20 +3,20 @@ module Gnuplot module Matrix def to_gplot (x = nil, y = nil) - xgrid = x || (0...self.column_size).to_a - ygrid = y || (0...self.row_size).to_a + xgrid = x || (0...self.column_size).to_a + ygrid = y || (0...self.row_size).to_a - f = "" - ygrid.length.times do |j| - y = ygrid[j] - xgrid.length.times do |i| - if ( self[j,i] ) then - f << "#{xgrid[i]} #{y} #{self[j,i]}\n" - end - end - end + f = "" + ygrid.length.times do |j| + y = ygrid[j] + xgrid.length.times do |i| + if ( self[j,i] ) then + f << "#{xgrid[i]} #{y} #{self[j,i]}\n" + end + end + end - f + f end end diff --git a/lib/gnuplot/plot.rb b/lib/gnuplot/plot.rb index 296c14f..d86b256 100644 --- a/lib/gnuplot/plot.rb +++ b/lib/gnuplot/plot.rb @@ -7,14 +7,14 @@ module Gnuplot class Plot attr_accessor :cmd, :data, :settings - QUOTED = [ "title", "output", "xlabel", "x2label", "ylabel", "y2label", "clabel", "cblabel", "zlabel" ] + QUOTED = %w(title output xlabel x2label ylabel y2label clabel cblabel zlabel) def initialize (io = nil, cmd = "plot") - @cmd = cmd - @settings = [] + @cmd = cmd + @settings = [] @arbitrary_lines = [] - @data = [] - @styles = [] + @data = [] + @styles = [] yield self if block_given? puts "writing this to gnuplot:\n" + to_gplot + "\n" if $VERBOSE @@ -59,9 +59,9 @@ def unset ( var ) def [] ( var ) v = @settings.rassoc( var ) if v.nil? or v.first == :unset - nil + nil else - v[2] + v[2] end end From 72604c03eef5d646e42536a8c505fdd3bd2b8d36 Mon Sep 17 00:00:00 2001 From: Ivan Sidarau Date: Mon, 21 Oct 2013 15:13:06 +0300 Subject: [PATCH 06/10] creating generating HeatMap plots available using SPlot and 3d Array --- ChangeLog | 3 +++ lib/gnuplot.rb | 10 +++++----- lib/gnuplot/array.rb | 4 ++-- lib/gnuplot/splot.rb | 14 +++++++++++++- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0698188..e0b3622 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2.6.2 +* adding to_gsplot for SPlot images, now you can draw HeatMap using [x, y, d ] arrays + 2.6.1 * TheKnight Fix bug in SPlot.to_gplot implementation. diff --git a/lib/gnuplot.rb b/lib/gnuplot.rb index ddb4196..1c0151d 100644 --- a/lib/gnuplot.rb +++ b/lib/gnuplot.rb @@ -4,11 +4,11 @@ # classes. require 'matrix' -require 'gnuplot/array' -require 'gnuplot/matrix' -require 'gnuplot/dataset' -require 'gnuplot/plot' -require 'gnuplot/splot' +require_relative 'gnuplot/array' +require_relative 'gnuplot/matrix' +require_relative 'gnuplot/dataset' +require_relative 'gnuplot/plot' +require_relative 'gnuplot/splot' module Gnuplot diff --git a/lib/gnuplot/array.rb b/lib/gnuplot/array.rb index 7180ac6..42a8740 100644 --- a/lib/gnuplot/array.rb +++ b/lib/gnuplot/array.rb @@ -1,6 +1,7 @@ module Gnuplot module Array def to_gplot + if ( self[0].kind_of? Array ) then tmp = self[0].zip( *self[1..-1] ) tmp.collect { |a| a.join(" ") }.join("\n") + "\ne" @@ -15,7 +16,6 @@ def to_gplot def to_gsplot f = "" - if ( self[0].kind_of? Array ) then x = self[0] y = self[1] @@ -25,7 +25,7 @@ def to_gsplot y.each_with_index do |yv, j| f << [ xv, yv, d[i][j] ].join(" ") << "\n" end - # f << "\n" + f << "\n" end elsif ( self[0].kind_of? Numeric ) then self.length.times do |i| f << "#{self[i]}\n" end diff --git a/lib/gnuplot/splot.rb b/lib/gnuplot/splot.rb index 5b0e411..427d47a 100644 --- a/lib/gnuplot/splot.rb +++ b/lib/gnuplot/splot.rb @@ -5,7 +5,7 @@ module Gnuplot class SPlot < Plot def initialize (io = nil, cmd = "splot") - super + super end # Currently using the implementation from parent class Plot. @@ -15,5 +15,17 @@ def to_gplot (io = "") super end + def store_datasets (io = "") + if @data.size > 0 + io << @cmd << " " << @data.collect { |e| e.plot_args }.join(", ") + io << "\n" + + v = @data.collect { |ds| ds.to_gsplot } + io << v.compact.join("e\n") + end + + io + end + end end From b5f6ea60b32caa4ac68dfcfdd9668e607ad5ec04 Mon Sep 17 00:00:00 2001 From: Ivan Sidarau Date: Mon, 21 Oct 2013 15:28:03 +0300 Subject: [PATCH 07/10] adding files to be created for gem --- Gemfile.lock | 16 ---------------- gnuplot.gemspec | 9 +++++++-- lib/gnuplot/version.rb | 2 +- 3 files changed, 8 insertions(+), 19 deletions(-) delete mode 100644 Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index df32583..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,16 +0,0 @@ -PATH - remote: . - specs: - gnuplot (2.6.1) - -GEM - remote: http://rubygems.org/ - specs: - rake (10.1.0) - -PLATFORMS - ruby - -DEPENDENCIES - gnuplot! - rake diff --git a/gnuplot.gemspec b/gnuplot.gemspec index 3b0d71f..548cf5e 100644 --- a/gnuplot.gemspec +++ b/gnuplot.gemspec @@ -2,13 +2,18 @@ $:.push File.expand_path("../lib", __FILE__) require "gnuplot/version" +lib_rb_files = Dir.glob( File.join( "lib", "**", "*.rb") ) +test_rb_files = Dir.glob( File.join( "test", "**", "*.rb") ) +examples_rb_files = Dir.glob( File.join( "examples", "**", "*.rb") ) + Gem::Specification.new do |s| s.name = 'gnuplot' - s.description = s.summary = "Utility library to aid in interacting with gnuplot from ruby" + s.description = "Utility library to aid in interacting with gnuplot from ruby" + s.summary = "Utility that could be used to create different types of plot (see gnuplot)." s.version = Gnuplot::VERSION s.authors = 'roger pack' s.email = "rogerpack2005@gmail.com" s.homepage = "http://github.com/rdp/ruby_gnuplot/tree/master" - + s.files = lib_rb_files + test_rb_files + examples_rb_files + [ "Rakefile" ] s.add_development_dependency 'rake' end diff --git a/lib/gnuplot/version.rb b/lib/gnuplot/version.rb index 8ad123b..6381183 100644 --- a/lib/gnuplot/version.rb +++ b/lib/gnuplot/version.rb @@ -1,3 +1,3 @@ module Gnuplot - VERSION = "2.6.1" + VERSION = "2.6.2" end From 9efbb0516a4c5554b54e62078ed70d5847877d4b Mon Sep 17 00:00:00 2001 From: Ivan Sidarau Date: Mon, 21 Oct 2013 15:57:21 +0300 Subject: [PATCH 08/10] adding pointtype, color modules, adding possibility to draw dots on HeatMap (using 3d array or 2d array) --- lib/gnuplot/array.rb | 41 +++++++++++++++++++++++++++++++---------- lib/gnuplot/dataset.rb | 23 +++++++++++++++++++++-- lib/gnuplot/splot.rb | 1 + 3 files changed, 53 insertions(+), 12 deletions(-) diff --git a/lib/gnuplot/array.rb b/lib/gnuplot/array.rb index 42a8740..3037345 100644 --- a/lib/gnuplot/array.rb +++ b/lib/gnuplot/array.rb @@ -17,24 +17,45 @@ def to_gplot def to_gsplot f = "" if ( self[0].kind_of? Array ) then + if self.size == 2 + f = to_gsplot2d() + else + f = to_gsplot3d() + end + elsif ( self[0].kind_of? Numeric ) then + self.length.times do |i| f << "#{self[i]}\n" end + else + self[0].zip( *self[1..-1] ).to_gsplot + end + f + end + private + def to_gsplot2d + f = "" x = self[0] y = self[1] - d = self[2] - x.each_with_index do |xv, i| y.each_with_index do |yv, j| - f << [ xv, yv, d[i][j] ].join(" ") << "\n" + f << [ xv, yv, 0 ].join(" ") << "\n" end f << "\n" end - elsif ( self[0].kind_of? Numeric ) then - self.length.times do |i| f << "#{self[i]}\n" end - else - self[0].zip( *self[1..-1] ).to_gsplot - end + f + end + def to_gsplot3d + f = "" + x = self[0] + y = self[1] + d = self[2] - f - end + x.each_with_index do |xv, i| + y.each_with_index do |yv, j| + f << [ xv, yv, d[i][j] ].join(" ") << "\n" + end + f << "\n" + end + f + end end end diff --git a/lib/gnuplot/dataset.rb b/lib/gnuplot/dataset.rb index 61eb063..b4aead6 100644 --- a/lib/gnuplot/dataset.rb +++ b/lib/gnuplot/dataset.rb @@ -14,15 +14,32 @@ module Gnuplot # # @todo Use the delegator to delegate to the data property. + module Color + BLACK = -1 + RED = 1 + GREEN = 2 + BLUE = 3 + end + module PointType + DOTTED = 0 + PLUS = 1 + X = 2 + MULTIPLY = 3 + EMPTY_SQUARE = 4 + FILLED_SQUARE = 5 + EMPTY_CIRCLE = 6 + FILLED_CIRCLE = 7 + end + class DataSet - attr_accessor :title, :with, :using, :data, :linewidth, :linecolor, :matrix, :smooth, :axes, :index, :linestyle + attr_accessor :title, :with, :using, :data, :linewidth, :linecolor, :matrix, :smooth, :axes, :index, :linestyle, :pointtype, :pointsize alias :ls :linestyle alias :ls= :linestyle= def initialize (data = nil) @data = data - @linestyle = @title = @with = @using = @linewidth = @linecolor = + @linestyle = @title = @with = @using = @linewidth = @linecolor = @pointtype = @pointsize @matrix = @smooth = @axes = @index = nil # avoid warnings yield self if block_given? end @@ -55,6 +72,8 @@ def plot_args (io = "") io << " linecolor #{@linecolor}" if @linecolor io << " linewidth #{@linewidth}" if @linewidth io << " linestyle #{@linestyle.index}" if @linestyle + io << " pointtype #{@pointtype}" if @pointtype + io << " pointsize #{@pointsize}" if @pointsize io end diff --git a/lib/gnuplot/splot.rb b/lib/gnuplot/splot.rb index 427d47a..28aaaa8 100644 --- a/lib/gnuplot/splot.rb +++ b/lib/gnuplot/splot.rb @@ -16,6 +16,7 @@ def to_gplot (io = "") end def store_datasets (io = "") + if @data.size > 0 io << @cmd << " " << @data.collect { |e| e.plot_args }.join(", ") io << "\n" From 7ff9b8b27a6eb82c10b012173a755d8c2c871312 Mon Sep 17 00:00:00 2001 From: Ivan Sidarau Date: Mon, 28 Oct 2013 13:49:39 +0300 Subject: [PATCH 09/10] adding last fixes --- gnuplot-2.6.2.gem | Bin 0 -> 10240 bytes lib/gnuplot/array.rb | 23 ++++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 gnuplot-2.6.2.gem diff --git a/gnuplot-2.6.2.gem b/gnuplot-2.6.2.gem new file mode 100644 index 0000000000000000000000000000000000000000..95e96ea8fd819be4dcc913604f0ef73c25db7684 GIT binary patch literal 10240 zcmeHsWlSARw=VAPS~e8eSYhK7cXxMp_oBt!wLo##QnW}Z?poa4i@R+0KJRx=?zvyS z+~njW=j7fW@AGG^nUz^H>zQP-CXc0=rx~lKnLDeEAI$$0K!1UUiwou-_AmU4W#{JM z;rQQk{~l-OXp%Y-Rs8KJn#d+)#>&p>T|d&x|rCR#7^N{Ic0udB+hsM)xLSE_dU6kc?` zS22u`Zg4jHvlSIG{4dVKYiflOi0nSj7RhZ??F8OCjA;kr2Y->fm)}23pjf1slof*@Y;yx?Z zu1A?n<6)K`l|?4$1s^sLYw>zU8{?tYz6*=`VqA1{KV9jh&Mhv1Qf4YawDpX)1=;Ht<=DCj+_n(AI0EZ4 ze)6`J;r16@USZ?4b+_R+W)aHA5DIV(nQx$;6$BI4>oe-$;n9SRG@}|&btl(s@gumt z0o`KceMm5i9_sHzOxuj(lmLmGV(MpW7Q2B|dY@B`y-?HATSlFN9AZ9J-u*0mMx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 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/gnuplot/dataset.rb b/lib/gnuplot/dataset.rb index b4aead6..444c2f8 100644 --- a/lib/gnuplot/dataset.rb +++ b/lib/gnuplot/dataset.rb @@ -32,7 +32,8 @@ module PointType end class DataSet - attr_accessor :title, :with, :using, :data, :linewidth, :linecolor, :matrix, :smooth, :axes, :index, :linestyle, :pointtype, :pointsize + attr_accessor :title, :with, :using, :data, :linewidth, :linecolor, :matrix, :smooth, :axes, :index + attr_accessor :linestyle, :pointtype, :pointsize, :fs, :fc alias :ls :linestyle alias :ls= :linestyle= @@ -40,7 +41,7 @@ class DataSet def initialize (data = nil) @data = data @linestyle = @title = @with = @using = @linewidth = @linecolor = @pointtype = @pointsize - @matrix = @smooth = @axes = @index = nil # avoid warnings + @matrix = @smooth = @axes = @index = @fs = @fc = nil # avoid warnings yield self if block_given? end @@ -69,6 +70,8 @@ def plot_args (io = "") io << " matrix" if @matrix io << " smooth #{@smooth}" if @smooth io << " with #{@with}" if @with + io << " fc #{@fs}" if @fc + io << " fs #{@fs}" if @fs io << " linecolor #{@linecolor}" if @linecolor io << " linewidth #{@linewidth}" if @linewidth io << " linestyle #{@linestyle.index}" if @linestyle