From de034858c7aca5ec8c77a5508f4b93256e752f2a Mon Sep 17 00:00:00 2001 From: Pierre Yager Date: Wed, 6 Feb 2013 23:24:55 +0100 Subject: [PATCH 01/55] Exposed DataSet#index property Use of index property is required for me to be able to draw a curve based on a simple dataset of values (x, y) : dataset = Gnuplot::DataSet.new( [x, y] ) do |ds| ds.with = "linespoints" ds.notitle ds.using = "1:2" ds.index = 0 end --- lib/gnuplot.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/gnuplot.rb b/lib/gnuplot.rb index 0ee51d4..89cae33 100644 --- a/lib/gnuplot.rb +++ b/lib/gnuplot.rb @@ -210,11 +210,11 @@ def to_gplot (io = "") # @todo Use the delegator to delegate to the data property. class DataSet - attr_accessor :title, :with, :using, :data, :linewidth, :linecolor, :matrix, :smooth, :axes + attr_accessor :title, :with, :using, :data, :linewidth, :linecolor, :matrix, :smooth, :axes, :index def initialize (data = nil) @data = data - @title = @with = @using = @linewidth = @linecolor = @matrix = @smooth = @axes = nil # avoid warnings + @title = @with = @using = @linewidth = @linecolor = @matrix = @smooth = @axes = @index = nil # avoid warnings yield self if block_given? end @@ -228,6 +228,8 @@ def plot_args (io = "") io << ( (@data.instance_of? String) ? @data : "'-'" ) + io << " index #{@index}" if @index + io << " using #{@using}" if @using io << " axes #{@axes}" if @axes From 9676b48855065062f25818cc23e71e219f722711 Mon Sep 17 00:00:00 2001 From: Rafael Rosa Fu Date: Tue, 12 Feb 2013 18:46:03 -0500 Subject: [PATCH 02/55] Make 3d_surface_plot behave like the other examples It was missing lib directory in the load path --- examples/3d_surface_plot.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/3d_surface_plot.rb b/examples/3d_surface_plot.rb index 3c02451..942d8ce 100644 --- a/examples/3d_surface_plot.rb +++ b/examples/3d_surface_plot.rb @@ -1,3 +1,4 @@ +$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__)) require "gnuplot" Gnuplot.open do |gp| @@ -11,4 +12,4 @@ ] end sleep 10 -end \ No newline at end of file +end From e7d2e541e7644c6073157bd9e1eeccc96758dbfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20M=C3=BCller?= Date: Tue, 30 Apr 2013 09:36:50 +0200 Subject: [PATCH 03/55] Add helper to create linestyles --- lib/gnuplot.rb | 69 ++++++++++++++++++++++++++++++++++++++++++-- test/test_gnuplot.rb | 28 ++++++++++++++++++ 2 files changed, 95 insertions(+), 2 deletions(-) diff --git a/lib/gnuplot.rb b/lib/gnuplot.rb index 89cae33..f8faf42 100644 --- a/lib/gnuplot.rb +++ b/lib/gnuplot.rb @@ -97,6 +97,7 @@ def initialize (io = nil, cmd = "plot") @settings = [] @arbitrary_lines = [] @data = [] + @styles = [] yield self if block_given? puts "writing this to gnuplot:\n" + to_gplot + "\n" if $VERBOSE @@ -147,6 +148,64 @@ def [] ( var ) 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 @@ -157,6 +216,7 @@ 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 @@ -210,11 +270,15 @@ def to_gplot (io = "") # @todo Use the delegator to delegate to the data property. class DataSet - attr_accessor :title, :with, :using, :data, :linewidth, :linecolor, :matrix, :smooth, :axes, :index + 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 - @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 @@ -245,6 +309,7 @@ def plot_args (io = "") io << " with #{@with}" if @with io << " linecolor #{@linecolor}" if @linecolor io << " linewidth #{@linewidth}" if @linewidth + io << " linestyle #{@linestyle.index}" if @linestyle io end diff --git a/test/test_gnuplot.rb b/test/test_gnuplot.rb index f873143..6b301e9 100644 --- a/test/test_gnuplot.rb +++ b/test/test_gnuplot.rb @@ -90,6 +90,34 @@ def test_unset assert_nil plot["title"] end + def test_style + plot = Gnuplot::Plot.new do |p| + s1 = p.style do |s| + s.ls = 1 + s.lt = 1 + s.lc = 1 + s.pt = 1 + s.ps = 1 + end + assert s1.to_s == "set style line 1 ls 1 lt 1 lc 1 pt 1 ps 1", "correct style definition" + assert s1.index == 1, "set index correctly" + + s2 = p.style do |s| + s.ls = 2 + end + assert s2.to_s == "set style line 2 ls 2", "correct style definition" + assert s2.index == 2, "index must be incremented" + + ds = Gnuplot::DataSet.new do |ds| + ds.with = "lines" + ds.linestyle = s1 + ds.data = [ [0, 1, 2], [1, 2, 5] ] + end + + assert ds.plot_args == "'-' with lines linestyle 1", "convert linestyle to index" # index of s1 + end + end + end From 5d827be315593d7bd6da44c2a6569acc7e6565a8 Mon Sep 17 00:00:00 2001 From: Russell Smith Date: Sat, 8 Mar 2014 13:49:13 -0800 Subject: [PATCH 04/55] Fix unescaped quote in example --- README.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.textile b/README.textile index e888dd6..04a0280 100644 --- a/README.textile +++ b/README.textile @@ -180,7 +180,7 @@ end You can also add arbitrary lines to the output
-plot.arbitrary_lines << "set ylabel \"y label" font \"Helvetica,20\""
+plot.arbitrary_lines << "set ylabel \"y label\" font \"Helvetica,20\""
 
See more in the examples folder. Also since this is basically just a wrapper for gnuplot itself, you should be able to do anything that it can do (demos: From d9c2b05417100b6fdc098321268e2ec6d2158875 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Sat, 15 Mar 2014 01:07:33 -0400 Subject: [PATCH 05/55] Handle empty arrays in Array#to_gplot. --- lib/gnuplot.rb | 81 ++++++++++++++++++++++---------------------- test/test_gnuplot.rb | 38 +++++++++++++-------- 2 files changed, 64 insertions(+), 55 deletions(-) diff --git a/lib/gnuplot.rb b/lib/gnuplot.rb index f8faf42..ff10a75 100644 --- a/lib/gnuplot.rb +++ b/lib/gnuplot.rb @@ -1,21 +1,21 @@ # 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' - + 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 +41,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 +61,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,11 +77,11 @@ def Gnuplot.open( persist=true ) io.close_write @output = io.read } - return @output + 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 @@ -101,7 +101,7 @@ def initialize (io = nil, cmd = "plot") yield self if block_given? puts "writing this to gnuplot:\n" + to_gplot + "\n" if $VERBOSE - if io + if io io << to_gplot io << store_datasets end @@ -119,7 +119,7 @@ def method_missing( methId, *args ) # 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. + # performed if the variable requires it. # # This is overloaded by the +method_missing+ method so see that for more # readable code. @@ -230,7 +230,7 @@ def store_datasets (io = "") v = @data.collect { |ds| ds.to_gplot } io << v.compact.join("e\n") end - + io end end @@ -243,7 +243,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 +258,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 +269,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 +295,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,19 +328,20 @@ def to_gsplot else @data.to_gsplot end end - + end end class Array def to_gplot - if ( self[0].kind_of? Array ) then + return "" if self.empty? + + case self[0] + when Array 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 + when Numeric + self.join("\n") else self[0].zip( *self[1..-1] ).to_gplot end @@ -348,7 +349,7 @@ def to_gplot def to_gsplot f = "" - + if ( self[0].kind_of? Array ) then x = self[0] y = self[1] @@ -365,16 +366,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 +385,7 @@ def to_gplot (x = nil, y = nil) end end end - + f end diff --git a/test/test_gnuplot.rb b/test/test_gnuplot.rb index 6b301e9..18d8e34 100644 --- a/test/test_gnuplot.rb +++ b/test/test_gnuplot.rb @@ -4,15 +4,23 @@ require 'test/unit' class StdDataTest < Test::Unit::TestCase - + def test_array_1d data = (0..5).to_a ds = Gnuplot::DataSet.new( data ) - + assert data == ds.data assert data.join("\n") + "\n", ds.to_gplot end + def test_empty_array + data = [] + ds = Gnuplot::DataSet.new( data ) + + assert data == ds.data + assert "" == ds.to_gplot + end + # Test a multidimensional array. @@ -20,10 +28,10 @@ def test_array_nd d1 = (0..3).to_a d2 = d1.collect { |v| 3 * v } d3 = d2.collect { |v| 4 * v } - + data = [ d1, d2, d3 ] ds = Gnuplot::DataSet.new( data ) - + assert data == ds.data assert "0 0 0\n1 3 12\n2 6 24\n3 9 36\n", ds.to_gplot end @@ -34,24 +42,24 @@ class DataSetTest < Test::Unit::TestCase def test_yield_ctor ds = Gnuplot::DataSet.new do |ds| - ds.with = "lines" + ds.with = "lines" ds.using = "1:2" ds.data = [ [0, 1, 2], [1, 2, 5] ] end - + assert "lines", ds.with assert "1:2", ds.using assert nil == ds.title assert [ [0, 1, 2], [1, 2, 5] ] == ds.data assert "'-' using 1:2 with lines", ds.plot_args - assert "0 1\n1 2\n2 5\n", ds.to_gplot + assert "0 1\n1 2\n2 5\n", ds.to_gplot end - + end class PlotTest < Test::Unit::TestCase - + def test_no_data plot = Gnuplot::Plot.new do |p| p.set "output", "'foo'" @@ -60,10 +68,10 @@ def test_no_data end assert( plot.settings == - [ [:set, "output", "'foo'"], + [ [:set, "output", "'foo'"], [:set, "terminal", "postscript enhanced"], [:unset, "border"] ] ) - + assert( plot.to_gplot, \ "set output 'foo'\nset terminal postscript enhanced\n" ) @@ -109,7 +117,7 @@ def test_style assert s2.index == 2, "index must be incremented" ds = Gnuplot::DataSet.new do |ds| - ds.with = "lines" + ds.with = "lines" ds.linestyle = s1 ds.data = [ [0, 1, 2], [1, 2, 5] ] end @@ -134,7 +142,7 @@ class GnuplotModuleTest def test_which # Put the spaces around the command to make sure that it gets stripped - # properly. + # properly. assert( CONFIG["SHELL"], Gnuplot::which(" sh " ) ) assert( CONFIG["SHELL"], Gnuplot::which( CONFIG["SHELL"] ) ) end @@ -151,10 +159,10 @@ def test_gnuplot # name (one that is in the path) then I should get the shell name as the # result of the gnuplot call. - ENV["RB_GNUPLOT"] = "sh" + ENV["RB_GNUPLOT"] = "sh" assert( CONFIG["SHELL"], Gnuplot.gnuplot(false) ) end - + end From 3062885c7635677210e6e956f737a8bbb0640cf6 Mon Sep 17 00:00:00 2001 From: Martin Asser Hansen Date: Wed, 25 Jun 2014 15:41:08 +0200 Subject: [PATCH 06/55] output verbose message to instead of --- lib/gnuplot.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gnuplot.rb b/lib/gnuplot.rb index ff10a75..592b3e6 100644 --- a/lib/gnuplot.rb +++ b/lib/gnuplot.rb @@ -99,7 +99,7 @@ def initialize (io = nil, cmd = "plot") @data = [] @styles = [] yield self if block_given? - puts "writing this to gnuplot:\n" + to_gplot + "\n" if $VERBOSE + $stderr.puts "writing this to gnuplot:\n" + to_gplot + "\n" if $VERBOSE if io io << to_gplot From 65a1167764fec113294c9d509e5c3a15f0aad7cb Mon Sep 17 00:00:00 2001 From: Joe Norton Date: Sun, 29 Jun 2014 21:03:58 -0700 Subject: [PATCH 07/55] add test as default task in rake --- Rakefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 850c6d3..d8ae9ee 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,5 @@ require 'jeweler2' -Jeweler::Tasks.new do |s| +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" @@ -8,6 +8,8 @@ Jeweler::Tasks.new do |s| s.homepage = "http://github.com/rdp/ruby_gnuplot/tree/master" end +task :default => :test + desc 'run unit tests' task :test do Dir.chdir 'test' From 11daf3a201a629be9916e89bdeca7bd1945d420e Mon Sep 17 00:00:00 2001 From: Dustin Morrill Date: Wed, 9 Jul 2014 13:15:23 -0600 Subject: [PATCH 08/55] Cleaned up packaging system, listed dependencies explicitly, removed warnings from tests, added tasks to Rakefile, and added version file --- Gemfile | 4 ++++ Rakefile | 36 ++++++++++++++++++++---------------- lib/ruby_gnuplot/version.rb | 3 +++ ruby_gnuplot.gemspec | 21 +++++++++++++++++++++ test/arrtest.rb | 12 ++++++------ test/histtest.rb | 4 ++-- test/multtest.rb | 12 ++++++------ test/sinwave.rb | 12 ++++++------ test/test_gnuplot.rb | 12 ++++++------ 9 files changed, 74 insertions(+), 42 deletions(-) create mode 100644 Gemfile create mode 100644 lib/ruby_gnuplot/version.rb create mode 100644 ruby_gnuplot.gemspec diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..1ad452f --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +# Specify your gem's dependencies in acpc_dealer.gemspec +gemspec diff --git a/Rakefile b/Rakefile index d8ae9ee..a0ac068 100644 --- a/Rakefile +++ b/Rakefile @@ -1,21 +1,25 @@ -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/gem_tasks" +require 'rake' +require 'rake/clean' +require 'rake/testtask' +require 'rubygems/package_task' -task :default => :test +require_relative 'lib/ruby_gnuplot/version' desc 'run unit tests' -task :test do - Dir.chdir 'test' - for file in Dir['*'] - system("ruby #{file}") - end +task :default => [:test] + +task :build + +Rake::TestTask.new do |t| + t.libs << "lib" << 'spec/support' + t.test_files = FileList['test/**/*.rb'] + t.verbose = false + t.warning = false +end + +def gemspec + @clean_gemspec ||= eval(File.read(File.expand_path('../ruby_gnuplot.gemspec', __FILE__))) end -Jeweler::RubygemsDotOrgTasks.new \ No newline at end of file +Gem::PackageTask.new(gemspec) { |pkg| } diff --git a/lib/ruby_gnuplot/version.rb b/lib/ruby_gnuplot/version.rb new file mode 100644 index 0000000..ba6c60b --- /dev/null +++ b/lib/ruby_gnuplot/version.rb @@ -0,0 +1,3 @@ +module RubyGnuplot + VERSION = "2.6.1" +end diff --git a/ruby_gnuplot.gemspec b/ruby_gnuplot.gemspec new file mode 100644 index 0000000..c9cf609 --- /dev/null +++ b/ruby_gnuplot.gemspec @@ -0,0 +1,21 @@ +# coding: utf-8 +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'ruby_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 = RubyGnuplot::VERSION + s.authors='roger pack' + s.email = "rogerpack2005@gmail.com" + s.homepage = "http://github.com/rdp/ruby_gnuplot/tree/master" + s.license = "BSD" + + s.files = `git ls-files`.split($/) + s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) } + s.test_files = s.files.grep(%r{^(test|spec|features)/}) + s.require_paths = ["lib"] + + s.add_development_dependency 'minitest' +end diff --git a/test/arrtest.rb b/test/arrtest.rb index 208072c..00a95a3 100644 --- a/test/arrtest.rb +++ b/test/arrtest.rb @@ -1,12 +1,12 @@ -require '../lib/gnuplot' +require 'gnuplot' Gnuplot.open do |gp| Gnuplot::Plot.new( gp ) do |plot| - + plot.title "Array Plot Example" plot.ylabel "x" plot.xlabel "x^2" - + x = (0..50).collect { |v| v.to_f } y = x.collect { |v| v ** 2 } @@ -14,8 +14,8 @@ ds.with = "linespoints" ds.notitle end - + end - + end - + diff --git a/test/histtest.rb b/test/histtest.rb index dd09e24..d90bc0d 100644 --- a/test/histtest.rb +++ b/test/histtest.rb @@ -1,4 +1,4 @@ -require '../lib/gnuplot' +require 'gnuplot' Gnuplot.open do |gp| gp << "bin(x, s) = s*int(x/s)\n" @@ -10,7 +10,7 @@ x = (0..500).collect { |v| (rand()-0.5)**3 } plot.data << Gnuplot::DataSet.new( [x] ) do |ds| - ds.title = "smooth frequency" + ds.title = "smooth frequency" ds.using = "(bin($1,.01)):(1.)" ds.smooth = "freq" ds.with = "boxes" diff --git a/test/multtest.rb b/test/multtest.rb index 1aeb1d5..3bf4983 100644 --- a/test/multtest.rb +++ b/test/multtest.rb @@ -1,14 +1,14 @@ -require '../lib/gnuplot' +require 'gnuplot' # File.open( "gnuplot.dat", "w") do |gp| Gnuplot.open do |gp| Gnuplot::Plot.new( gp ) do |plot| - + plot.xrange "[-10:10]" plot.title "Sin Wave Example" plot.ylabel "x" plot.xlabel "sin(x)" - + x = (0..50).collect { |v| v.to_f } y = x.collect { |v| v ** 2 } @@ -18,7 +18,7 @@ ds.title = "String function" ds.linewidth = 4 }, - + Gnuplot::DataSet.new( [x, y] ) { |ds| ds.with = "linespoints" ds.title = "Array data" @@ -26,6 +26,6 @@ ] end - + end - + diff --git a/test/sinwave.rb b/test/sinwave.rb index f7e7131..78db32e 100644 --- a/test/sinwave.rb +++ b/test/sinwave.rb @@ -1,19 +1,19 @@ -require '../lib/gnuplot' +require 'gnuplot' Gnuplot.open do |gp| Gnuplot::Plot.new( gp ) do |plot| - + plot.xrange "[-10:10]" plot.title "Sin Wave Example" plot.ylabel "x" plot.xlabel "sin(x)" - + plot.data << Gnuplot::DataSet.new( "sin(x)" ) do |ds| ds.with = "lines" ds.linewidth = 4 end - + end - + end - + diff --git a/test/test_gnuplot.rb b/test/test_gnuplot.rb index 18d8e34..19b7625 100644 --- a/test/test_gnuplot.rb +++ b/test/test_gnuplot.rb @@ -1,9 +1,9 @@ # -*- ruby -*- -require '../lib/gnuplot' -require 'test/unit' +require 'gnuplot' +require 'minitest/autorun' -class StdDataTest < Test::Unit::TestCase +class StdDataTest < MiniTest::Test def test_array_1d data = (0..5).to_a @@ -38,7 +38,7 @@ def test_array_nd end -class DataSetTest < Test::Unit::TestCase +class DataSetTest < MiniTest::Test def test_yield_ctor ds = Gnuplot::DataSet.new do |ds| @@ -58,7 +58,7 @@ def test_yield_ctor end -class PlotTest < Test::Unit::TestCase +class PlotTest < MiniTest::Test def test_no_data plot = Gnuplot::Plot.new do |p| @@ -130,7 +130,7 @@ def test_style require 'rbconfig' -CONFIG = Config::MAKEFILE_CONFIG +CONFIG = RbConfig::MAKEFILE_CONFIG # This attempts to test the functions that comprise the gnuplot package. Most # of the bug reports that I get for this package have to do with finding the From 8e5d872fdfc14f1f94d9f12a3108211e84b53007 Mon Sep 17 00:00:00 2001 From: Dustin Morrill Date: Wed, 9 Jul 2014 13:19:56 -0600 Subject: [PATCH 09/55] Update Rakefile Removed unnecessary explicit task --- Rakefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index a0ac068..bc3514b 100644 --- a/Rakefile +++ b/Rakefile @@ -7,9 +7,7 @@ require 'rubygems/package_task' require_relative 'lib/ruby_gnuplot/version' desc 'run unit tests' -task :default => [:test] - -task :build +task :default => :test Rake::TestTask.new do |t| t.libs << "lib" << 'spec/support' From 6b9ebad96b35b43aa42bd53e03b48f0fbf14686c Mon Sep 17 00:00:00 2001 From: Dustin Morrill Date: Wed, 9 Jul 2014 13:20:31 -0600 Subject: [PATCH 10/55] Update Gemfile Fixed copy-paste typo --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 1ad452f..3ef8ff9 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ source 'https://rubygems.org' -# Specify your gem's dependencies in acpc_dealer.gemspec +# Specify your gem's dependencies in ruby_gnuplot.gemspec gemspec From 4c1147fcc5564268650445a9c8bbabb2e86149b8 Mon Sep 17 00:00:00 2001 From: Rakibul Islam Date: Sun, 19 Jul 2015 18:08:34 -0400 Subject: [PATCH 11/55] Installation steps and ReadMe Cleanups * Pre-requisites and Installation steps to use gnuplot gem * Updated ReadMe for better readability --- README.textile | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.textile b/README.textile index 04a0280..9a42805 100644 --- a/README.textile +++ b/README.textile @@ -14,6 +14,17 @@ h2. History and Background been using it actively ever since. Now rdp maintains it. See also the changelog for more detail. +h2. Pre-requisites and Installation + + 1. Install XQuartz from here: + @http://xquartz.macosforge.org/landing/@ + + 2. Install gnuplot with homebrew: + @brew install gnuplot --with-x11@ + + 3. Install gnuplot gem: + @gem install gnuplot@ + h2. Ruby Gnuplot Concepts Gnuplot has a very simple conceptual model. Calls to _Set_ are @@ -29,11 +40,11 @@ h2. Ruby Gnuplot Concepts plot: -# Instantiate a @Plot@ or @Splot@ object and set parameters by gnuplot variable name. + 1. Instantiate a @Plot@ or @Splot@ object and set parameters by gnuplot variable name. -# Instantiate @DataSet@ objects and attach Ruby objects containing the data to be plotted to the @DataSet@. Attach properties that modify the plot command using the modifier name. + 2. Instantiate @DataSet@ objects and attach Ruby objects containing the data to be plotted to the @DataSet@. Attach properties that modify the plot command using the modifier name. -# Send the @Plot@/@Splot@ object to a @Gnuplot@ instance for plotting. + 3. Send the @Plot@/@Splot@ object to a @Gnuplot@ instance for plotting. The Version 2.0 interface makes very heavy use of blocks leading to very readable code. From 3d5c2c61afe02223203d1987ed757e18825b9e1d Mon Sep 17 00:00:00 2001 From: Jay Hayes Date: Fri, 2 Dec 2016 05:10:23 -0600 Subject: [PATCH 12/55] Fix axis labels in example --- README.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.textile b/README.textile index 9a42805..9f43cb9 100644 --- a/README.textile +++ b/README.textile @@ -111,8 +111,8 @@ Gnuplot.open do |gp| plot.xrange "[-10:10]" plot.title "Sin Wave Example" - plot.ylabel "x" - plot.xlabel "sin(x)" + plot.xlabel "x" + plot.ylabel "sin(x)" plot.data << Gnuplot::DataSet.new( "sin(x)" ) do |ds| ds.with = "lines" From d943c06822be71f0c41d107f09f85e938269a639 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Fri, 1 Sep 2017 10:34:39 +0100 Subject: [PATCH 13/55] correct spelling mistake --- README.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.textile b/README.textile index 9f43cb9..4ec5086 100644 --- a/README.textile +++ b/README.textile @@ -30,7 +30,7 @@ h2. Ruby Gnuplot Concepts Gnuplot has a very simple conceptual model. Calls to _Set_ are made to set parameters and either _Plot_ or _Splot_ is called to generate the actual plot. The _dataset_ to be - plotted can be specified in a number of ways, contained in a seperate + plotted can be specified in a number of ways, contained in a separate file, generated from a function, read from standard input, or read immediately after the plot command. From 21db9771ba37ba9ca29f2259273ef44b1a784b6e Mon Sep 17 00:00:00 2001 From: darthjee Date: Fri, 25 Oct 2019 18:39:40 +0200 Subject: [PATCH 14/55] Add docker compose and docker file --- Dockerfile | 10 ++++++++++ docker-compose.yml | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b547c13 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM ruby:2.5.0 as base + +RUN useradd -u 1000 gnuplot; \ + mkdir -p /home/gnuplot/gnuplot; \ + chown gnuplot.gnuplot -R /home/gnuplot + +WORKDIR /home/gnuplot/gnuplot + +USER gnuplot +RUN gem install bundler diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a57db23 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3' +services: + base: &base + image: ruby_gnuplot + working_dir: /home/gnuplot/gnuplot + volumes: + - .:/home/gnuplot/gnuplot + + base_build: + <<: *base + build: . + command: echo done + + ruby_gnuplot: + <<: *base + container_name: ruby_gnuplot + depends_on: [base_build] From 6d8492f1a7a3dc3d8c8d2d1ed067d293f33552c7 Mon Sep 17 00:00:00 2001 From: darthjee Date: Fri, 25 Oct 2019 18:54:22 +0200 Subject: [PATCH 15/55] Install needed packages --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b547c13..fc14e49 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM ruby:2.5.0 as base +RUN apt-get update && apt-get install -y gnuplot + RUN useradd -u 1000 gnuplot; \ mkdir -p /home/gnuplot/gnuplot; \ chown gnuplot.gnuplot -R /home/gnuplot @@ -7,4 +9,4 @@ RUN useradd -u 1000 gnuplot; \ WORKDIR /home/gnuplot/gnuplot USER gnuplot -RUN gem install bundler +RUN gem install jeweler2 From 43f5fbf7ed3e6fe00165f2076b069739b90d6cbc Mon Sep 17 00:00:00 2001 From: darthjee Date: Mon, 28 Oct 2019 12:27:42 +0100 Subject: [PATCH 16/55] Chnage entrypoint --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index a57db23..92cfe29 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,3 +15,4 @@ services: <<: *base container_name: ruby_gnuplot depends_on: [base_build] + command: /bin/bash From 39b45e92e314b9c433ba636210e80d07c86fa03c Mon Sep 17 00:00:00 2001 From: darthjee Date: Mon, 28 Oct 2019 12:29:51 +0100 Subject: [PATCH 17/55] Simplify docker-compose file --- docker-compose.yml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 92cfe29..61d4e71 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,18 +1,9 @@ version: '3' services: - base: &base - image: ruby_gnuplot - working_dir: /home/gnuplot/gnuplot - volumes: - - .:/home/gnuplot/gnuplot - - base_build: - <<: *base - build: . - command: echo done - ruby_gnuplot: - <<: *base + build: . + working_dir: /home/gnuplot/gnuplot container_name: ruby_gnuplot - depends_on: [base_build] command: /bin/bash + volumes: + - .:/home/gnuplot/gnuplot From e7b7c648fc262b54d2d8c0cbabf1d2a23002d911 Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 6 Nov 2019 20:15:32 +0100 Subject: [PATCH 18/55] Update dockerfile acording to new bundle format --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fc14e49..b6d5643 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,4 +9,7 @@ RUN useradd -u 1000 gnuplot; \ WORKDIR /home/gnuplot/gnuplot USER gnuplot -RUN gem install jeweler2 + +COPY ./ ./ + +RUN gem install bundler; bundle install From 3e2d95b5ad1df794c703fe3e0b4ea8aad75e5462 Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 6 Nov 2019 21:16:44 +0100 Subject: [PATCH 19/55] Add gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b844b14 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Gemfile.lock From 7b23f81eacef4a15b7fd4affffa565484db58c34 Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 6 Nov 2019 22:21:24 +0100 Subject: [PATCH 20/55] Avoid Gnuplot.lock copy --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b6d5643..8123674 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,8 @@ WORKDIR /home/gnuplot/gnuplot USER gnuplot -COPY ./ ./ +COPY lib/ ./lib/ +COPY *.gemspec ./ +COPY Gemfile ./ RUN gem install bundler; bundle install From 7cd0b4cc670ea66a6e8497c99f409915790f81db Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 6 Nov 2019 21:13:33 +0100 Subject: [PATCH 21/55] Add rspec --- ruby_gnuplot.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/ruby_gnuplot.gemspec b/ruby_gnuplot.gemspec index c9cf609..c0fcedc 100644 --- a/ruby_gnuplot.gemspec +++ b/ruby_gnuplot.gemspec @@ -18,4 +18,5 @@ Gem::Specification.new do |s| s.require_paths = ["lib"] s.add_development_dependency 'minitest' + s.add_development_dependency 'rspec', '3.9.0' end From 5024cdd840e33afaee5e2ff02c8fee5a7531bc82 Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 6 Nov 2019 21:14:51 +0100 Subject: [PATCH 22/55] add rspec --- .rspec | 2 + spec/spec_helper.rb | 100 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 .rspec create mode 100644 spec/spec_helper.rb diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..3687797 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--require spec_helper +--color diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..251aa51 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,100 @@ +# This file was generated by the `rspec --init` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # This allows you to limit a spec run to individual examples or groups + # you care about by tagging them with `:focus` metadata. When nothing + # is tagged with `:focus`, all examples get run. RSpec also provides + # aliases for `it`, `describe`, and `context` that include `:focus` + # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + config.filter_run_when_matching :focus + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + config.disable_monkey_patching! + + # This setting enables warnings. It's recommended, but in some cases may + # be too noisy due to issues in dependencies. + config.warnings = true + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = "doc" + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end From 8e42b9082f8a709031e9e80b7c4e682c544ea158 Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 6 Nov 2019 22:04:00 +0100 Subject: [PATCH 23/55] Add arrtest_spec --- spec/integration/arrtest_spec.rb | 39 ++++++++++++++++++++++++++++++++ spec/spec_helper.rb | 2 ++ spec/tmp/.keep | 0 3 files changed, 41 insertions(+) create mode 100644 spec/integration/arrtest_spec.rb create mode 100644 spec/tmp/.keep diff --git a/spec/integration/arrtest_spec.rb b/spec/integration/arrtest_spec.rb new file mode 100644 index 0000000..f0e3bbf --- /dev/null +++ b/spec/integration/arrtest_spec.rb @@ -0,0 +1,39 @@ +describe "Array Plot Example" do + let(:file_path) { 'spec/tmp/array_plot.eps' } + let(:fixture_path) { 'spec/fixtures/plots/array_plot.eps' } + + let(:file_content) { File.read(file_path) } + let(:fixture_content) { File.read(fixture_path) } + + before do + path = file_path + + Gnuplot.open do |gp| + Gnuplot::Plot.new( gp ) do |plot| + + plot.title "Array Plot Example" + plot.ylabel "x" + plot.xlabel "x^2" + plot.set "term","postscript eps" + plot.set "out", "'#{path}'" + + x = (0..50).collect { |v| v.to_f } + y = x.collect { |v| v ** 2 } + + plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds| + ds.with = "linespoints" + ds.notitle + end + end + end + + end + + after do + File.delete(file_path) + end + + it do + expect(file_content).to eq(fixture_content) + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 251aa51..8e96672 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,6 +13,8 @@ # it. # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +require "gnuplot" + RSpec.configure do |config| # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest diff --git a/spec/tmp/.keep b/spec/tmp/.keep new file mode 100644 index 0000000..e69de29 From b6742ae88ea71a8321890ab912528c5b306207f1 Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 6 Nov 2019 22:28:45 +0100 Subject: [PATCH 24/55] Add sample example for arr_spec --- spec/fixtures/plots/array_plot.eps | 810 +++++++++++++++++++++++++++++ spec/integration/arrtest_spec.rb | 9 +- 2 files changed, 817 insertions(+), 2 deletions(-) create mode 100644 spec/fixtures/plots/array_plot.eps diff --git a/spec/fixtures/plots/array_plot.eps b/spec/fixtures/plots/array_plot.eps new file mode 100644 index 0000000..98b8de1 --- /dev/null +++ b/spec/fixtures/plots/array_plot.eps @@ -0,0 +1,810 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: spec/tmp/array_plot.eps +%%Creator: gnuplot 5.0 patchlevel 5 +%%CreationDate: Wed Nov 6 21:24:07 2019 +%%DocumentFonts: (atend) +%%BoundingBox: 50 50 410 302 +%%EndComments +%%BeginProlog +/gnudict 256 dict def +gnudict begin +% +% The following true/false flags may be edited by hand if desired. +% The unit line width and grayscale image gamma correction may also be changed. +% +/Color false def +/Blacktext false def +/Solid false def +/Dashlength 1 def +/Landscape false def +/Level1 false def +/Level3 false def +/Rounded false def +/ClipToBoundingBox false def +/SuppressPDFMark false def +/TransparentPatterns false def +/gnulinewidth 5.000 def +/userlinewidth gnulinewidth def +/Gamma 1.0 def +/BackgroundColor {-1.000 -1.000 -1.000} def +% +/vshift -46 def +/dl1 { + 10.0 Dashlength userlinewidth gnulinewidth div mul mul mul + Rounded { currentlinewidth 0.75 mul sub dup 0 le { pop 0.01 } if } if +} def +/dl2 { + 10.0 Dashlength userlinewidth gnulinewidth div mul mul mul + Rounded { currentlinewidth 0.75 mul add } if +} def +/hpt_ 31.5 def +/vpt_ 31.5 def +/hpt hpt_ def +/vpt vpt_ def +/doclip { + ClipToBoundingBox { + newpath 50 50 moveto 410 50 lineto 410 302 lineto 50 302 lineto closepath + clip + } if +} def +% +% Gnuplot Prolog Version 5.1 (Oct 2015) +% +%/SuppressPDFMark true def +% +/M {moveto} bind def +/L {lineto} bind def +/R {rmoveto} bind def +/V {rlineto} bind def +/N {newpath moveto} bind def +/Z {closepath} bind def +/C {setrgbcolor} bind def +/f {rlineto fill} bind def +/g {setgray} bind def +/Gshow {show} def % May be redefined later in the file to support UTF-8 +/vpt2 vpt 2 mul def +/hpt2 hpt 2 mul def +/Lshow {currentpoint stroke M 0 vshift R + Blacktext {gsave 0 setgray textshow grestore} {textshow} ifelse} def +/Rshow {currentpoint stroke M dup stringwidth pop neg vshift R + Blacktext {gsave 0 setgray textshow grestore} {textshow} ifelse} def +/Cshow {currentpoint stroke M dup stringwidth pop -2 div vshift R + Blacktext {gsave 0 setgray textshow grestore} {textshow} ifelse} def +/UP {dup vpt_ mul /vpt exch def hpt_ mul /hpt exch def + /hpt2 hpt 2 mul def /vpt2 vpt 2 mul def} def +/DL {Color {setrgbcolor Solid {pop []} if 0 setdash} + {pop pop pop 0 setgray Solid {pop []} if 0 setdash} ifelse} def +/BL {stroke userlinewidth 2 mul setlinewidth + Rounded {1 setlinejoin 1 setlinecap} if} def +/AL {stroke userlinewidth 2 div setlinewidth + Rounded {1 setlinejoin 1 setlinecap} if} def +/UL {dup gnulinewidth mul /userlinewidth exch def + dup 1 lt {pop 1} if 10 mul /udl exch def} def +/PL {stroke userlinewidth setlinewidth + Rounded {1 setlinejoin 1 setlinecap} if} def +3.8 setmiterlimit +% Classic Line colors (version 5.0) +/LCw {1 1 1} def +/LCb {0 0 0} def +/LCa {0 0 0} def +/LC0 {1 0 0} def +/LC1 {0 1 0} def +/LC2 {0 0 1} def +/LC3 {1 0 1} def +/LC4 {0 1 1} def +/LC5 {1 1 0} def +/LC6 {0 0 0} def +/LC7 {1 0.3 0} def +/LC8 {0.5 0.5 0.5} def +% Default dash patterns (version 5.0) +/LTB {BL [] LCb DL} def +/LTw {PL [] 1 setgray} def +/LTb {PL [] LCb DL} def +/LTa {AL [1 udl mul 2 udl mul] 0 setdash LCa setrgbcolor} def +/LT0 {PL [] LC0 DL} def +/LT1 {PL [2 dl1 3 dl2] LC1 DL} def +/LT2 {PL [1 dl1 1.5 dl2] LC2 DL} def +/LT3 {PL [6 dl1 2 dl2 1 dl1 2 dl2] LC3 DL} def +/LT4 {PL [1 dl1 2 dl2 6 dl1 2 dl2 1 dl1 2 dl2] LC4 DL} def +/LT5 {PL [4 dl1 2 dl2] LC5 DL} def +/LT6 {PL [1.5 dl1 1.5 dl2 1.5 dl1 1.5 dl2 1.5 dl1 6 dl2] LC6 DL} def +/LT7 {PL [3 dl1 3 dl2 1 dl1 3 dl2] LC7 DL} def +/LT8 {PL [2 dl1 2 dl2 2 dl1 6 dl2] LC8 DL} def +/SL {[] 0 setdash} def +/Pnt {stroke [] 0 setdash gsave 1 setlinecap M 0 0 V stroke grestore} def +/Dia {stroke [] 0 setdash 2 copy vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V closepath stroke + Pnt} def +/Pls {stroke [] 0 setdash vpt sub M 0 vpt2 V + currentpoint stroke M + hpt neg vpt neg R hpt2 0 V stroke + } def +/Box {stroke [] 0 setdash 2 copy exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V closepath stroke + Pnt} def +/Crs {stroke [] 0 setdash exch hpt sub exch vpt add M + hpt2 vpt2 neg V currentpoint stroke M + hpt2 neg 0 R hpt2 vpt2 V stroke} def +/TriU {stroke [] 0 setdash 2 copy vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V closepath stroke + Pnt} def +/Star {2 copy Pls Crs} def +/BoxF {stroke [] 0 setdash exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V closepath fill} def +/TriUF {stroke [] 0 setdash vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V closepath fill} def +/TriD {stroke [] 0 setdash 2 copy vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V closepath stroke + Pnt} def +/TriDF {stroke [] 0 setdash vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V closepath fill} def +/DiaF {stroke [] 0 setdash vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V closepath fill} def +/Pent {stroke [] 0 setdash 2 copy gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + closepath stroke grestore Pnt} def +/PentF {stroke [] 0 setdash gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + closepath fill grestore} def +/Circle {stroke [] 0 setdash 2 copy + hpt 0 360 arc stroke Pnt} def +/CircleF {stroke [] 0 setdash hpt 0 360 arc fill} def +/C0 {BL [] 0 setdash 2 copy moveto vpt 90 450 arc} bind def +/C1 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 90 arc closepath fill + vpt 0 360 arc closepath} bind def +/C2 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 90 180 arc closepath fill + vpt 0 360 arc closepath} bind def +/C3 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 180 arc closepath fill + vpt 0 360 arc closepath} bind def +/C4 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 180 270 arc closepath fill + vpt 0 360 arc closepath} bind def +/C5 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 90 arc + 2 copy moveto + 2 copy vpt 180 270 arc closepath fill + vpt 0 360 arc} bind def +/C6 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 90 270 arc closepath fill + vpt 0 360 arc closepath} bind def +/C7 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 270 arc closepath fill + vpt 0 360 arc closepath} bind def +/C8 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 270 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/C9 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 270 450 arc closepath fill + vpt 0 360 arc closepath} bind def +/C10 {BL [] 0 setdash 2 copy 2 copy moveto vpt 270 360 arc closepath fill + 2 copy moveto + 2 copy vpt 90 180 arc closepath fill + vpt 0 360 arc closepath} bind def +/C11 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 180 arc closepath fill + 2 copy moveto + 2 copy vpt 270 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/C12 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 180 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/C13 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 90 arc closepath fill + 2 copy moveto + 2 copy vpt 180 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/C14 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 90 360 arc closepath fill + vpt 0 360 arc} bind def +/C15 {BL [] 0 setdash 2 copy vpt 0 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/Rec {newpath 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto + neg 0 rlineto closepath} bind def +/Square {dup Rec} bind def +/Bsquare {vpt sub exch vpt sub exch vpt2 Square} bind def +/S0 {BL [] 0 setdash 2 copy moveto 0 vpt rlineto BL Bsquare} bind def +/S1 {BL [] 0 setdash 2 copy vpt Square fill Bsquare} bind def +/S2 {BL [] 0 setdash 2 copy exch vpt sub exch vpt Square fill Bsquare} bind def +/S3 {BL [] 0 setdash 2 copy exch vpt sub exch vpt2 vpt Rec fill Bsquare} bind def +/S4 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt Square fill Bsquare} bind def +/S5 {BL [] 0 setdash 2 copy 2 copy vpt Square fill + exch vpt sub exch vpt sub vpt Square fill Bsquare} bind def +/S6 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill Bsquare} bind def +/S7 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill + 2 copy vpt Square fill Bsquare} bind def +/S8 {BL [] 0 setdash 2 copy vpt sub vpt Square fill Bsquare} bind def +/S9 {BL [] 0 setdash 2 copy vpt sub vpt vpt2 Rec fill Bsquare} bind def +/S10 {BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt Square fill + Bsquare} bind def +/S11 {BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt2 vpt Rec fill + Bsquare} bind def +/S12 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill Bsquare} bind def +/S13 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill + 2 copy vpt Square fill Bsquare} bind def +/S14 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill + 2 copy exch vpt sub exch vpt Square fill Bsquare} bind def +/S15 {BL [] 0 setdash 2 copy Bsquare fill Bsquare} bind def +/D0 {gsave translate 45 rotate 0 0 S0 stroke grestore} bind def +/D1 {gsave translate 45 rotate 0 0 S1 stroke grestore} bind def +/D2 {gsave translate 45 rotate 0 0 S2 stroke grestore} bind def +/D3 {gsave translate 45 rotate 0 0 S3 stroke grestore} bind def +/D4 {gsave translate 45 rotate 0 0 S4 stroke grestore} bind def +/D5 {gsave translate 45 rotate 0 0 S5 stroke grestore} bind def +/D6 {gsave translate 45 rotate 0 0 S6 stroke grestore} bind def +/D7 {gsave translate 45 rotate 0 0 S7 stroke grestore} bind def +/D8 {gsave translate 45 rotate 0 0 S8 stroke grestore} bind def +/D9 {gsave translate 45 rotate 0 0 S9 stroke grestore} bind def +/D10 {gsave translate 45 rotate 0 0 S10 stroke grestore} bind def +/D11 {gsave translate 45 rotate 0 0 S11 stroke grestore} bind def +/D12 {gsave translate 45 rotate 0 0 S12 stroke grestore} bind def +/D13 {gsave translate 45 rotate 0 0 S13 stroke grestore} bind def +/D14 {gsave translate 45 rotate 0 0 S14 stroke grestore} bind def +/D15 {gsave translate 45 rotate 0 0 S15 stroke grestore} bind def +/DiaE {stroke [] 0 setdash vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V closepath stroke} def +/BoxE {stroke [] 0 setdash exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V closepath stroke} def +/TriUE {stroke [] 0 setdash vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V closepath stroke} def +/TriDE {stroke [] 0 setdash vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V closepath stroke} def +/PentE {stroke [] 0 setdash gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + closepath stroke grestore} def +/CircE {stroke [] 0 setdash + hpt 0 360 arc stroke} def +/Opaque {gsave closepath 1 setgray fill grestore 0 setgray closepath} def +/DiaW {stroke [] 0 setdash vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V Opaque stroke} def +/BoxW {stroke [] 0 setdash exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V Opaque stroke} def +/TriUW {stroke [] 0 setdash vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V Opaque stroke} def +/TriDW {stroke [] 0 setdash vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V Opaque stroke} def +/PentW {stroke [] 0 setdash gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + Opaque stroke grestore} def +/CircW {stroke [] 0 setdash + hpt 0 360 arc Opaque stroke} def +/BoxFill {gsave Rec 1 setgray fill grestore} def +/Density { + /Fillden exch def + currentrgbcolor + /ColB exch def /ColG exch def /ColR exch def + /ColR ColR Fillden mul Fillden sub 1 add def + /ColG ColG Fillden mul Fillden sub 1 add def + /ColB ColB Fillden mul Fillden sub 1 add def + ColR ColG ColB setrgbcolor} def +/BoxColFill {gsave Rec PolyFill} def +/PolyFill {gsave Density fill grestore grestore} def +/h {rlineto rlineto rlineto gsave closepath fill grestore} bind def +% +% PostScript Level 1 Pattern Fill routine for rectangles +% Usage: x y w h s a XX PatternFill +% x,y = lower left corner of box to be filled +% w,h = width and height of box +% a = angle in degrees between lines and x-axis +% XX = 0/1 for no/yes cross-hatch +% +/PatternFill {gsave /PFa [ 9 2 roll ] def + PFa 0 get PFa 2 get 2 div add PFa 1 get PFa 3 get 2 div add translate + PFa 2 get -2 div PFa 3 get -2 div PFa 2 get PFa 3 get Rec + TransparentPatterns {} {gsave 1 setgray fill grestore} ifelse + clip + currentlinewidth 0.5 mul setlinewidth + /PFs PFa 2 get dup mul PFa 3 get dup mul add sqrt def + 0 0 M PFa 5 get rotate PFs -2 div dup translate + 0 1 PFs PFa 4 get div 1 add floor cvi + {PFa 4 get mul 0 M 0 PFs V} for + 0 PFa 6 get ne { + 0 1 PFs PFa 4 get div 1 add floor cvi + {PFa 4 get mul 0 2 1 roll M PFs 0 V} for + } if + stroke grestore} def +% +/languagelevel where + {pop languagelevel} {1} ifelse +dup 2 lt + {/InterpretLevel1 true def + /InterpretLevel3 false def} + {/InterpretLevel1 Level1 def + 2 gt + {/InterpretLevel3 Level3 def} + {/InterpretLevel3 false def} + ifelse } + ifelse +% +% PostScript level 2 pattern fill definitions +% +/Level2PatternFill { +/Tile8x8 {/PaintType 2 /PatternType 1 /TilingType 1 /BBox [0 0 8 8] /XStep 8 /YStep 8} + bind def +/KeepColor {currentrgbcolor [/Pattern /DeviceRGB] setcolorspace} bind def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 0 0 M 8 8 L 0 8 M 8 0 L stroke} +>> matrix makepattern +/Pat1 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 0 0 M 8 8 L 0 8 M 8 0 L stroke + 0 4 M 4 8 L 8 4 L 4 0 L 0 4 L stroke} +>> matrix makepattern +/Pat2 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 0 0 M 0 8 L + 8 8 L 8 0 L 0 0 L fill} +>> matrix makepattern +/Pat3 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop -4 8 M 8 -4 L + 0 12 M 12 0 L stroke} +>> matrix makepattern +/Pat4 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop -4 0 M 8 12 L + 0 -4 M 12 8 L stroke} +>> matrix makepattern +/Pat5 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop -2 8 M 4 -4 L + 0 12 M 8 -4 L 4 12 M 10 0 L stroke} +>> matrix makepattern +/Pat6 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop -2 0 M 4 12 L + 0 -4 M 8 12 L 4 -4 M 10 8 L stroke} +>> matrix makepattern +/Pat7 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 8 -2 M -4 4 L + 12 0 M -4 8 L 12 4 M 0 10 L stroke} +>> matrix makepattern +/Pat8 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 0 -2 M 12 4 L + -4 0 M 12 8 L -4 4 M 8 10 L stroke} +>> matrix makepattern +/Pat9 exch def +/Pattern1 {PatternBgnd KeepColor Pat1 setpattern} bind def +/Pattern2 {PatternBgnd KeepColor Pat2 setpattern} bind def +/Pattern3 {PatternBgnd KeepColor Pat3 setpattern} bind def +/Pattern4 {PatternBgnd KeepColor Landscape {Pat5} {Pat4} ifelse setpattern} bind def +/Pattern5 {PatternBgnd KeepColor Landscape {Pat4} {Pat5} ifelse setpattern} bind def +/Pattern6 {PatternBgnd KeepColor Landscape {Pat9} {Pat6} ifelse setpattern} bind def +/Pattern7 {PatternBgnd KeepColor Landscape {Pat8} {Pat7} ifelse setpattern} bind def +} def +% +% +%End of PostScript Level 2 code +% +/PatternBgnd { + TransparentPatterns {} {gsave 1 setgray fill grestore} ifelse +} def +% +% Substitute for Level 2 pattern fill codes with +% grayscale if Level 2 support is not selected. +% +/Level1PatternFill { +/Pattern1 {0.250 Density} bind def +/Pattern2 {0.500 Density} bind def +/Pattern3 {0.750 Density} bind def +/Pattern4 {0.125 Density} bind def +/Pattern5 {0.375 Density} bind def +/Pattern6 {0.625 Density} bind def +/Pattern7 {0.875 Density} bind def +} def +% +% Now test for support of Level 2 code +% +Level1 {Level1PatternFill} {Level2PatternFill} ifelse +% +/Symbol-Oblique /Symbol findfont [1 0 .167 1 0 0] makefont +dup length dict begin {1 index /FID eq {pop pop} {def} ifelse} forall +currentdict end definefont pop +% +/MFshow { + { dup 5 get 3 ge + { 5 get 3 eq {gsave} {grestore} ifelse } + {dup dup 0 get findfont exch 1 get scalefont setfont + [ currentpoint ] exch dup 2 get 0 exch R dup 5 get 2 ne {dup dup 6 + get exch 4 get {textshow} {stringwidth pop 0 R} ifelse }if dup 5 get 0 eq + {dup 3 get {2 get neg 0 exch R pop} {pop aload pop M} ifelse} {dup 5 + get 1 eq {dup 2 get exch dup 3 get exch 6 get stringwidth pop -2 div + dup 0 R} {dup 6 get stringwidth pop -2 div 0 R 6 get + textshow 2 index {aload pop M neg 3 -1 roll neg R pop pop} {pop pop pop + pop aload pop M} ifelse }ifelse }ifelse } + ifelse } + forall} def +/Gswidth {dup type /stringtype eq {stringwidth} {pop (n) stringwidth} ifelse} def +/MFwidth {0 exch { dup 5 get 3 ge { 5 get 3 eq { 0 } { pop } ifelse } + {dup 3 get{dup dup 0 get findfont exch 1 get scalefont setfont + 6 get Gswidth pop add} {pop} ifelse} ifelse} forall} def +/MLshow { currentpoint stroke M + 0 exch R + Blacktext {gsave 0 setgray MFshow grestore} {MFshow} ifelse } bind def +/MRshow { currentpoint stroke M + exch dup MFwidth neg 3 -1 roll R + Blacktext {gsave 0 setgray MFshow grestore} {MFshow} ifelse } bind def +/MCshow { currentpoint stroke M + exch dup MFwidth -2 div 3 -1 roll R + Blacktext {gsave 0 setgray MFshow grestore} {MFshow} ifelse } bind def +/XYsave { [( ) 1 2 true false 3 ()] } bind def +/XYrestore { [( ) 1 2 true false 4 ()] } bind def +Level1 SuppressPDFMark or +{} { +/SDict 10 dict def +systemdict /pdfmark known not { + userdict /pdfmark systemdict /cleartomark get put +} if +SDict begin [ + /Title (spec/tmp/array_plot.eps) + /Subject (gnuplot plot) + /Creator (gnuplot 5.0 patchlevel 5) +% /Producer (gnuplot) +% /Keywords () + /CreationDate (Wed Nov 6 21:24:07 2019) + /DOCINFO pdfmark +end +} ifelse +% +% Support for boxed text - Ethan A Merritt May 2005 +% +/InitTextBox { userdict /TBy2 3 -1 roll put userdict /TBx2 3 -1 roll put + userdict /TBy1 3 -1 roll put userdict /TBx1 3 -1 roll put + /Boxing true def } def +/ExtendTextBox { Boxing + { gsave dup false charpath pathbbox + dup TBy2 gt {userdict /TBy2 3 -1 roll put} {pop} ifelse + dup TBx2 gt {userdict /TBx2 3 -1 roll put} {pop} ifelse + dup TBy1 lt {userdict /TBy1 3 -1 roll put} {pop} ifelse + dup TBx1 lt {userdict /TBx1 3 -1 roll put} {pop} ifelse + grestore } if } def +/PopTextBox { newpath TBx1 TBxmargin sub TBy1 TBymargin sub M + TBx1 TBxmargin sub TBy2 TBymargin add L + TBx2 TBxmargin add TBy2 TBymargin add L + TBx2 TBxmargin add TBy1 TBymargin sub L closepath } def +/DrawTextBox { PopTextBox stroke /Boxing false def} def +/FillTextBox { gsave PopTextBox 1 1 1 setrgbcolor fill grestore /Boxing false def} def +0 0 0 0 InitTextBox +/TBxmargin 20 def +/TBymargin 20 def +/Boxing false def +/textshow { ExtendTextBox Gshow } def +% +% redundant definitions for compatibility with prologue.ps older than 5.0.2 +/LTB {BL [] LCb DL} def +/LTb {PL [] LCb DL} def +end +%%EndProlog +%%Page: 1 1 +gnudict begin +gsave +doclip +50 50 translate +0.050 0.050 scale +0 setgray +newpath +(Helvetica) findfont 140 scalefont setfont +BackgroundColor 0 lt 3 1 roll 0 lt exch 0 lt or or not {BackgroundColor C 1.000 0 0 7200.00 5040.00 BoxColFill} if +1.000 UL +LTb +LCb setrgbcolor +770 588 M +63 0 V +6114 0 R +-63 0 V +stroke +686 588 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 0)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +770 1394 M +63 0 V +6114 0 R +-63 0 V +stroke +686 1394 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 500)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +770 2200 M +63 0 V +6114 0 R +-63 0 V +stroke +686 2200 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 1000)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +770 3007 M +63 0 V +6114 0 R +-63 0 V +stroke +686 3007 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 1500)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +770 3813 M +63 0 V +6114 0 R +-63 0 V +stroke +686 3813 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 2000)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +770 4619 M +63 0 V +6114 0 R +-63 0 V +stroke +686 4619 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 2500)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +770 588 M +0 63 V +0 3968 R +0 -63 V +stroke +770 448 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 0)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +2005 588 M +0 63 V +0 3968 R +0 -63 V +stroke +2005 448 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 10)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +3241 588 M +0 63 V +0 3968 R +0 -63 V +stroke +3241 448 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 20)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +4476 588 M +0 63 V +0 3968 R +0 -63 V +stroke +4476 448 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 30)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +5712 588 M +0 63 V +0 3968 R +0 -63 V +stroke +5712 448 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 40)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +6947 588 M +0 63 V +0 3968 R +0 -63 V +stroke +6947 448 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 50)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +1.000 UL +LTB +LCb setrgbcolor +770 4619 N +770 588 L +6177 0 V +0 4031 V +-6177 0 V +Z stroke +1.000 UP +1.000 UL +LTb +LCb setrgbcolor +LCb setrgbcolor +112 2603 M +currentpoint gsave translate -270 rotate 0 0 moveto +[ [(Helvetica) 140.0 0.0 true true 0 (x)] +] -46.7 MCshow +grestore +LTb +LCb setrgbcolor +3858 238 M +[ [(Helvetica) 140.0 0.0 true true 0 (x)] +[(Helvetica) 112.0 70.0 true true 0 (2)] +] -60.7 MCshow +LTb +LCb setrgbcolor +3858 4829 M +[ [(Helvetica) 140.0 0.0 true true 0 (Array Plot Example)] +] -46.7 MCshow +% Begin plot #1 +1.000 UP +1.000 UL +LTb +LCb setrgbcolor +770 588 M +124 2 V +123 4 V +124 9 V +123 11 V +124 14 V +123 18 V +124 21 V +123 24 V +124 28 V +123 30 V +124 34 V +123 37 V +124 40 V +124 44 V +123 47 V +124 50 V +123 53 V +124 56 V +123 60 V +124 63 V +123 66 V +124 69 V +123 73 V +124 76 V +124 79 V +123 82 V +124 85 V +123 89 V +124 92 V +123 95 V +124 99 V +123 101 V +124 105 V +123 108 V +124 111 V +123 115 V +124 117 V +124 121 V +123 124 V +124 128 V +123 130 V +124 134 V +123 137 V +124 141 V +123 143 V +124 147 V +123 150 V +124 153 V +123 156 V +124 160 V +770 588 Pls +894 590 Pls +1017 594 Pls +1141 603 Pls +1264 614 Pls +1388 628 Pls +1511 646 Pls +1635 667 Pls +1758 691 Pls +1882 719 Pls +2005 749 Pls +2129 783 Pls +2252 820 Pls +2376 860 Pls +2500 904 Pls +2623 951 Pls +2747 1001 Pls +2870 1054 Pls +2994 1110 Pls +3117 1170 Pls +3241 1233 Pls +3364 1299 Pls +3488 1368 Pls +3611 1441 Pls +3735 1517 Pls +3859 1596 Pls +3982 1678 Pls +4106 1763 Pls +4229 1852 Pls +4353 1944 Pls +4476 2039 Pls +4600 2138 Pls +4723 2239 Pls +4847 2344 Pls +4970 2452 Pls +5094 2563 Pls +5217 2678 Pls +5341 2795 Pls +5465 2916 Pls +5588 3040 Pls +5712 3168 Pls +5835 3298 Pls +5959 3432 Pls +6082 3569 Pls +6206 3710 Pls +6329 3853 Pls +6453 4000 Pls +6576 4150 Pls +6700 4303 Pls +6823 4459 Pls +6947 4619 Pls +% End plot #1 +2.000 UL +LTb +LCb setrgbcolor +1.000 UL +LTB +LCb setrgbcolor +770 4619 N +770 588 L +6177 0 V +0 4031 V +-6177 0 V +Z stroke +1.000 UP +1.000 UL +LTb +LCb setrgbcolor +stroke +grestore +end +showpage +%%Trailer +%%DocumentFonts: Helvetica diff --git a/spec/integration/arrtest_spec.rb b/spec/integration/arrtest_spec.rb index f0e3bbf..9af5de0 100644 --- a/spec/integration/arrtest_spec.rb +++ b/spec/integration/arrtest_spec.rb @@ -2,8 +2,13 @@ let(:file_path) { 'spec/tmp/array_plot.eps' } let(:fixture_path) { 'spec/fixtures/plots/array_plot.eps' } - let(:file_content) { File.read(file_path) } - let(:fixture_content) { File.read(fixture_path) } + let(:file_content) do + File.read(file_path).gsub(/CreationDate.*/, "") + end + + let(:fixture_content) do + File.read(fixture_path).gsub(/CreationDate.*/, "") + end before do path = file_path From b97fb8c423e2afb3068b79e64833ec525c5b4491 Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 6 Nov 2019 22:29:05 +0100 Subject: [PATCH 25/55] Ignore swap files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b844b14..e82255f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ Gemfile.lock +**/*.swp From 1c72ea5810db9ed47e77c2ccf8132474d5921404 Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 6 Nov 2019 22:29:37 +0100 Subject: [PATCH 26/55] Add expectation description --- spec/integration/arrtest_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/integration/arrtest_spec.rb b/spec/integration/arrtest_spec.rb index 9af5de0..592a50e 100644 --- a/spec/integration/arrtest_spec.rb +++ b/spec/integration/arrtest_spec.rb @@ -38,7 +38,7 @@ File.delete(file_path) end - it do + it "plots expected file" do expect(file_content).to eq(fixture_content) end end From 2b577b1aaf8f0b46aff09d8cbd0b20ffcf420055 Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 6 Nov 2019 22:44:37 +0100 Subject: [PATCH 27/55] Add simple plot spec proposal --- spec/lib/ruby_gnuplot/plot_spec.rb | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 spec/lib/ruby_gnuplot/plot_spec.rb diff --git a/spec/lib/ruby_gnuplot/plot_spec.rb b/spec/lib/ruby_gnuplot/plot_spec.rb new file mode 100644 index 0000000..3a53e43 --- /dev/null +++ b/spec/lib/ruby_gnuplot/plot_spec.rb @@ -0,0 +1,32 @@ +describe Gnuplot::Plot do + subject(:plot) { described_class.new } + + describe '#to_gplot' do + context 'when nothing has been set' do + it "returns an empty string" do + expect(plot.to_gplot).to eq('') + end + end + + context 'when titles and labels have been set' do + let(:expected_string) do + [ + 'set title "Array Plot Example"', + 'set ylabel "x"', + 'set xlabel "x^2"', + '' + ].join("\n") + end + + before do + plot.title "Array Plot Example" + plot.ylabel "x" + plot.xlabel "x^2" + end + + it "sets title and axis labels" do + expect(plot.to_gplot).to eq(expected_string) + end + end + end +end From f550805b7af3ac556a8721a6a834b2f98404ca47 Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 6 Nov 2019 22:55:12 +0100 Subject: [PATCH 28/55] Improove gplot spec --- spec/integration/arrtest_spec.rb | 4 +-- spec/lib/ruby_gnuplot/plot_spec.rb | 39 ++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/spec/integration/arrtest_spec.rb b/spec/integration/arrtest_spec.rb index 592a50e..e496bab 100644 --- a/spec/integration/arrtest_spec.rb +++ b/spec/integration/arrtest_spec.rb @@ -19,8 +19,8 @@ plot.title "Array Plot Example" plot.ylabel "x" plot.xlabel "x^2" - plot.set "term","postscript eps" - plot.set "out", "'#{path}'" + plot.set "term","postscript eps" + plot.set "out", "'#{path}'" x = (0..50).collect { |v| v.to_f } y = x.collect { |v| v ** 2 } diff --git a/spec/lib/ruby_gnuplot/plot_spec.rb b/spec/lib/ruby_gnuplot/plot_spec.rb index 3a53e43..c45ce23 100644 --- a/spec/lib/ruby_gnuplot/plot_spec.rb +++ b/spec/lib/ruby_gnuplot/plot_spec.rb @@ -2,6 +2,18 @@ subject(:plot) { described_class.new } describe '#to_gplot' do + let(:expected_string) do + [ + 'set title "Array Plot Example"', + 'set ylabel "x"', + 'set xlabel "x^2"', + 'set term postscript eps', + 'set output "file.eps"', + '' + ].join("\n") + end + + context 'when nothing has been set' do it "returns an empty string" do expect(plot.to_gplot).to eq('') @@ -9,22 +21,29 @@ end context 'when titles and labels have been set' do - let(:expected_string) do - [ - 'set title "Array Plot Example"', - 'set ylabel "x"', - 'set xlabel "x^2"', - '' - ].join("\n") - end - before do plot.title "Array Plot Example" plot.ylabel "x" plot.xlabel "x^2" + plot.term "postscript eps" + plot.output "file.eps" + end + + it "wraps strings with quotes when needed" do + expect(plot.to_gplot).to eq(expected_string) + end + end + + context 'when variables are set throgh set call' do + before do + plot.set "title", "Array Plot Example" + plot.set "ylabel", "x" + plot.set "xlabel", "x^2" + plot.set "term", "postscript eps" + plot.set "output", "file.eps" end - it "sets title and axis labels" do + it "wraps strings with quotes when needed" do expect(plot.to_gplot).to eq(expected_string) end end From 64fc5de32320f81044b0771ba49d03df709a36dd Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 6 Nov 2019 22:58:14 +0100 Subject: [PATCH 29/55] Use correct format --- spec/integration/arrtest_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/integration/arrtest_spec.rb b/spec/integration/arrtest_spec.rb index e496bab..a5ae38e 100644 --- a/spec/integration/arrtest_spec.rb +++ b/spec/integration/arrtest_spec.rb @@ -19,8 +19,8 @@ plot.title "Array Plot Example" plot.ylabel "x" plot.xlabel "x^2" - plot.set "term","postscript eps" - plot.set "out", "'#{path}'" + plot.term "postscript eps" + plot.output path x = (0..50).collect { |v| v.to_f } y = x.collect { |v| v ** 2 } From 17290ecd36b996605e12e259c791685f657ff7f4 Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 6 Nov 2019 23:02:24 +0100 Subject: [PATCH 30/55] Add simplecov --- ruby_gnuplot.gemspec | 3 ++- spec/spec_helper.rb | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ruby_gnuplot.gemspec b/ruby_gnuplot.gemspec index c0fcedc..c070c96 100644 --- a/ruby_gnuplot.gemspec +++ b/ruby_gnuplot.gemspec @@ -18,5 +18,6 @@ Gem::Specification.new do |s| s.require_paths = ["lib"] s.add_development_dependency 'minitest' - s.add_development_dependency 'rspec', '3.9.0' + s.add_development_dependency 'rspec', '3.9.0' + s.add_development_dependency 'simplecov', '0.17.0' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8e96672..051338c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,6 +13,11 @@ # it. # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +require 'simplecov' +SimpleCov.start do + add_filter '/spec/' +end + require "gnuplot" RSpec.configure do |config| From 97e2b8cfb7e2763b6150643cc3cbd31808795f33 Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 6 Nov 2019 23:02:43 +0100 Subject: [PATCH 31/55] Add coverage to ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e82255f..97c645a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ Gemfile.lock **/*.swp +coverage/ From 7c6ebdf2f44f6abbb7f96a39b88e0f7bc0fc286f Mon Sep 17 00:00:00 2001 From: darthjee Date: Fri, 22 Nov 2019 22:15:17 +0100 Subject: [PATCH 32/55] Replace whitespaces --- test/histtest.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/histtest.rb b/test/histtest.rb index d90bc0d..9207005 100644 --- a/test/histtest.rb +++ b/test/histtest.rb @@ -1,20 +1,20 @@ require 'gnuplot' Gnuplot.open do |gp| - gp << "bin(x, s) = s*int(x/s)\n" + gp << "bin(x, s) = s*int(x/s)\n" - Gnuplot::Plot.new( gp ) do |plot| - plot.title "Histogram" - plot.xlabel "x" - plot.ylabel "frequency" + Gnuplot::Plot.new( gp ) do |plot| + plot.title "Histogram" + plot.xlabel "x" + plot.ylabel "frequency" - x = (0..500).collect { |v| (rand()-0.5)**3 } - plot.data << Gnuplot::DataSet.new( [x] ) do |ds| - ds.title = "smooth frequency" - ds.using = "(bin($1,.01)):(1.)" - ds.smooth = "freq" - ds.with = "boxes" - end + x = (0..500).collect { |v| (rand()-0.5)**3 } + plot.data << Gnuplot::DataSet.new( [x] ) do |ds| + ds.title = "smooth frequency" + ds.using = "(bin($1,.01)):(1.)" + ds.smooth = "freq" + ds.with = "boxes" end + end end From 82c4eb816ecfd48ebc77275db76ebe99f0720c45 Mon Sep 17 00:00:00 2001 From: darthjee Date: Fri, 22 Nov 2019 22:40:24 +0100 Subject: [PATCH 33/55] Add histogram spec --- spec/integration/histtest_spec.rb | 48 +++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 spec/integration/histtest_spec.rb diff --git a/spec/integration/histtest_spec.rb b/spec/integration/histtest_spec.rb new file mode 100644 index 0000000..47d7aea --- /dev/null +++ b/spec/integration/histtest_spec.rb @@ -0,0 +1,48 @@ +describe "Histogram Plot Example" do + let(:file_path) { 'spec/tmp/histogram_plot.eps' } + let(:fixture_path) { 'spec/fixtures/plots/histogram_plot.eps' } + + let(:file_content) do + File.read(file_path).gsub(/CreationDate.*/, "") + end + + let(:fixture_content) do + File.read(fixture_path).gsub(/CreationDate.*/, "") + end + + before do + path = file_path + collection = (0..500).collect do |_v| + (rand()-0.5)**3 + end + + Gnuplot.open do |gp| + gp << "bin(x, s) = s*int(x/s)\n" + + Gnuplot::Plot.new( gp ) do |plot| + plot.title "Histogram" + plot.xlabel "x" + plot.ylabel "frequency" + + plot.data << Gnuplot::DataSet.new( [collection] ) do |ds| + ds.title = "smooth frequency" + ds.using = "(bin($1,.01)):(1.)" + ds.smooth = "freq" + ds.with = "boxes" + end + + plot.term "postscript eps" + plot.output path + end + end + + end + + after do + File.delete(file_path) + end + + it "plots expected file" do + expect(file_content).to eq(fixture_content) + end +end From 9037db89e6f556b7d6a81c12e5b9aed2e7fe8630 Mon Sep 17 00:00:00 2001 From: darthjee Date: Fri, 22 Nov 2019 23:12:26 +0100 Subject: [PATCH 34/55] Fix histogram spec --- spec/fixtures/plots/histogram_plot.eps | 889 ++++++++++++++++++++++++ spec/integration/histtest_spec.rb | 4 +- spec/spec_helper.rb | 4 + spec/support/models/random_generator.rb | 18 + 4 files changed, 914 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/plots/histogram_plot.eps create mode 100644 spec/support/models/random_generator.rb diff --git a/spec/fixtures/plots/histogram_plot.eps b/spec/fixtures/plots/histogram_plot.eps new file mode 100644 index 0000000..c2edc90 --- /dev/null +++ b/spec/fixtures/plots/histogram_plot.eps @@ -0,0 +1,889 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: spec/tmp/histogram_plot.eps +%%Creator: gnuplot 5.0 patchlevel 5 +%%CreationDate: Fri Nov 22 22:11:02 2019 +%%DocumentFonts: (atend) +%%BoundingBox: 50 50 410 302 +%%EndComments +%%BeginProlog +/gnudict 256 dict def +gnudict begin +% +% The following true/false flags may be edited by hand if desired. +% The unit line width and grayscale image gamma correction may also be changed. +% +/Color false def +/Blacktext false def +/Solid false def +/Dashlength 1 def +/Landscape false def +/Level1 false def +/Level3 false def +/Rounded false def +/ClipToBoundingBox false def +/SuppressPDFMark false def +/TransparentPatterns false def +/gnulinewidth 5.000 def +/userlinewidth gnulinewidth def +/Gamma 1.0 def +/BackgroundColor {-1.000 -1.000 -1.000} def +% +/vshift -46 def +/dl1 { + 10.0 Dashlength userlinewidth gnulinewidth div mul mul mul + Rounded { currentlinewidth 0.75 mul sub dup 0 le { pop 0.01 } if } if +} def +/dl2 { + 10.0 Dashlength userlinewidth gnulinewidth div mul mul mul + Rounded { currentlinewidth 0.75 mul add } if +} def +/hpt_ 31.5 def +/vpt_ 31.5 def +/hpt hpt_ def +/vpt vpt_ def +/doclip { + ClipToBoundingBox { + newpath 50 50 moveto 410 50 lineto 410 302 lineto 50 302 lineto closepath + clip + } if +} def +% +% Gnuplot Prolog Version 5.1 (Oct 2015) +% +%/SuppressPDFMark true def +% +/M {moveto} bind def +/L {lineto} bind def +/R {rmoveto} bind def +/V {rlineto} bind def +/N {newpath moveto} bind def +/Z {closepath} bind def +/C {setrgbcolor} bind def +/f {rlineto fill} bind def +/g {setgray} bind def +/Gshow {show} def % May be redefined later in the file to support UTF-8 +/vpt2 vpt 2 mul def +/hpt2 hpt 2 mul def +/Lshow {currentpoint stroke M 0 vshift R + Blacktext {gsave 0 setgray textshow grestore} {textshow} ifelse} def +/Rshow {currentpoint stroke M dup stringwidth pop neg vshift R + Blacktext {gsave 0 setgray textshow grestore} {textshow} ifelse} def +/Cshow {currentpoint stroke M dup stringwidth pop -2 div vshift R + Blacktext {gsave 0 setgray textshow grestore} {textshow} ifelse} def +/UP {dup vpt_ mul /vpt exch def hpt_ mul /hpt exch def + /hpt2 hpt 2 mul def /vpt2 vpt 2 mul def} def +/DL {Color {setrgbcolor Solid {pop []} if 0 setdash} + {pop pop pop 0 setgray Solid {pop []} if 0 setdash} ifelse} def +/BL {stroke userlinewidth 2 mul setlinewidth + Rounded {1 setlinejoin 1 setlinecap} if} def +/AL {stroke userlinewidth 2 div setlinewidth + Rounded {1 setlinejoin 1 setlinecap} if} def +/UL {dup gnulinewidth mul /userlinewidth exch def + dup 1 lt {pop 1} if 10 mul /udl exch def} def +/PL {stroke userlinewidth setlinewidth + Rounded {1 setlinejoin 1 setlinecap} if} def +3.8 setmiterlimit +% Classic Line colors (version 5.0) +/LCw {1 1 1} def +/LCb {0 0 0} def +/LCa {0 0 0} def +/LC0 {1 0 0} def +/LC1 {0 1 0} def +/LC2 {0 0 1} def +/LC3 {1 0 1} def +/LC4 {0 1 1} def +/LC5 {1 1 0} def +/LC6 {0 0 0} def +/LC7 {1 0.3 0} def +/LC8 {0.5 0.5 0.5} def +% Default dash patterns (version 5.0) +/LTB {BL [] LCb DL} def +/LTw {PL [] 1 setgray} def +/LTb {PL [] LCb DL} def +/LTa {AL [1 udl mul 2 udl mul] 0 setdash LCa setrgbcolor} def +/LT0 {PL [] LC0 DL} def +/LT1 {PL [2 dl1 3 dl2] LC1 DL} def +/LT2 {PL [1 dl1 1.5 dl2] LC2 DL} def +/LT3 {PL [6 dl1 2 dl2 1 dl1 2 dl2] LC3 DL} def +/LT4 {PL [1 dl1 2 dl2 6 dl1 2 dl2 1 dl1 2 dl2] LC4 DL} def +/LT5 {PL [4 dl1 2 dl2] LC5 DL} def +/LT6 {PL [1.5 dl1 1.5 dl2 1.5 dl1 1.5 dl2 1.5 dl1 6 dl2] LC6 DL} def +/LT7 {PL [3 dl1 3 dl2 1 dl1 3 dl2] LC7 DL} def +/LT8 {PL [2 dl1 2 dl2 2 dl1 6 dl2] LC8 DL} def +/SL {[] 0 setdash} def +/Pnt {stroke [] 0 setdash gsave 1 setlinecap M 0 0 V stroke grestore} def +/Dia {stroke [] 0 setdash 2 copy vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V closepath stroke + Pnt} def +/Pls {stroke [] 0 setdash vpt sub M 0 vpt2 V + currentpoint stroke M + hpt neg vpt neg R hpt2 0 V stroke + } def +/Box {stroke [] 0 setdash 2 copy exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V closepath stroke + Pnt} def +/Crs {stroke [] 0 setdash exch hpt sub exch vpt add M + hpt2 vpt2 neg V currentpoint stroke M + hpt2 neg 0 R hpt2 vpt2 V stroke} def +/TriU {stroke [] 0 setdash 2 copy vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V closepath stroke + Pnt} def +/Star {2 copy Pls Crs} def +/BoxF {stroke [] 0 setdash exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V closepath fill} def +/TriUF {stroke [] 0 setdash vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V closepath fill} def +/TriD {stroke [] 0 setdash 2 copy vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V closepath stroke + Pnt} def +/TriDF {stroke [] 0 setdash vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V closepath fill} def +/DiaF {stroke [] 0 setdash vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V closepath fill} def +/Pent {stroke [] 0 setdash 2 copy gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + closepath stroke grestore Pnt} def +/PentF {stroke [] 0 setdash gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + closepath fill grestore} def +/Circle {stroke [] 0 setdash 2 copy + hpt 0 360 arc stroke Pnt} def +/CircleF {stroke [] 0 setdash hpt 0 360 arc fill} def +/C0 {BL [] 0 setdash 2 copy moveto vpt 90 450 arc} bind def +/C1 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 90 arc closepath fill + vpt 0 360 arc closepath} bind def +/C2 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 90 180 arc closepath fill + vpt 0 360 arc closepath} bind def +/C3 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 180 arc closepath fill + vpt 0 360 arc closepath} bind def +/C4 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 180 270 arc closepath fill + vpt 0 360 arc closepath} bind def +/C5 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 90 arc + 2 copy moveto + 2 copy vpt 180 270 arc closepath fill + vpt 0 360 arc} bind def +/C6 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 90 270 arc closepath fill + vpt 0 360 arc closepath} bind def +/C7 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 270 arc closepath fill + vpt 0 360 arc closepath} bind def +/C8 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 270 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/C9 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 270 450 arc closepath fill + vpt 0 360 arc closepath} bind def +/C10 {BL [] 0 setdash 2 copy 2 copy moveto vpt 270 360 arc closepath fill + 2 copy moveto + 2 copy vpt 90 180 arc closepath fill + vpt 0 360 arc closepath} bind def +/C11 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 180 arc closepath fill + 2 copy moveto + 2 copy vpt 270 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/C12 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 180 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/C13 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 90 arc closepath fill + 2 copy moveto + 2 copy vpt 180 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/C14 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 90 360 arc closepath fill + vpt 0 360 arc} bind def +/C15 {BL [] 0 setdash 2 copy vpt 0 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/Rec {newpath 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto + neg 0 rlineto closepath} bind def +/Square {dup Rec} bind def +/Bsquare {vpt sub exch vpt sub exch vpt2 Square} bind def +/S0 {BL [] 0 setdash 2 copy moveto 0 vpt rlineto BL Bsquare} bind def +/S1 {BL [] 0 setdash 2 copy vpt Square fill Bsquare} bind def +/S2 {BL [] 0 setdash 2 copy exch vpt sub exch vpt Square fill Bsquare} bind def +/S3 {BL [] 0 setdash 2 copy exch vpt sub exch vpt2 vpt Rec fill Bsquare} bind def +/S4 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt Square fill Bsquare} bind def +/S5 {BL [] 0 setdash 2 copy 2 copy vpt Square fill + exch vpt sub exch vpt sub vpt Square fill Bsquare} bind def +/S6 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill Bsquare} bind def +/S7 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill + 2 copy vpt Square fill Bsquare} bind def +/S8 {BL [] 0 setdash 2 copy vpt sub vpt Square fill Bsquare} bind def +/S9 {BL [] 0 setdash 2 copy vpt sub vpt vpt2 Rec fill Bsquare} bind def +/S10 {BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt Square fill + Bsquare} bind def +/S11 {BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt2 vpt Rec fill + Bsquare} bind def +/S12 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill Bsquare} bind def +/S13 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill + 2 copy vpt Square fill Bsquare} bind def +/S14 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill + 2 copy exch vpt sub exch vpt Square fill Bsquare} bind def +/S15 {BL [] 0 setdash 2 copy Bsquare fill Bsquare} bind def +/D0 {gsave translate 45 rotate 0 0 S0 stroke grestore} bind def +/D1 {gsave translate 45 rotate 0 0 S1 stroke grestore} bind def +/D2 {gsave translate 45 rotate 0 0 S2 stroke grestore} bind def +/D3 {gsave translate 45 rotate 0 0 S3 stroke grestore} bind def +/D4 {gsave translate 45 rotate 0 0 S4 stroke grestore} bind def +/D5 {gsave translate 45 rotate 0 0 S5 stroke grestore} bind def +/D6 {gsave translate 45 rotate 0 0 S6 stroke grestore} bind def +/D7 {gsave translate 45 rotate 0 0 S7 stroke grestore} bind def +/D8 {gsave translate 45 rotate 0 0 S8 stroke grestore} bind def +/D9 {gsave translate 45 rotate 0 0 S9 stroke grestore} bind def +/D10 {gsave translate 45 rotate 0 0 S10 stroke grestore} bind def +/D11 {gsave translate 45 rotate 0 0 S11 stroke grestore} bind def +/D12 {gsave translate 45 rotate 0 0 S12 stroke grestore} bind def +/D13 {gsave translate 45 rotate 0 0 S13 stroke grestore} bind def +/D14 {gsave translate 45 rotate 0 0 S14 stroke grestore} bind def +/D15 {gsave translate 45 rotate 0 0 S15 stroke grestore} bind def +/DiaE {stroke [] 0 setdash vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V closepath stroke} def +/BoxE {stroke [] 0 setdash exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V closepath stroke} def +/TriUE {stroke [] 0 setdash vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V closepath stroke} def +/TriDE {stroke [] 0 setdash vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V closepath stroke} def +/PentE {stroke [] 0 setdash gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + closepath stroke grestore} def +/CircE {stroke [] 0 setdash + hpt 0 360 arc stroke} def +/Opaque {gsave closepath 1 setgray fill grestore 0 setgray closepath} def +/DiaW {stroke [] 0 setdash vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V Opaque stroke} def +/BoxW {stroke [] 0 setdash exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V Opaque stroke} def +/TriUW {stroke [] 0 setdash vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V Opaque stroke} def +/TriDW {stroke [] 0 setdash vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V Opaque stroke} def +/PentW {stroke [] 0 setdash gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + Opaque stroke grestore} def +/CircW {stroke [] 0 setdash + hpt 0 360 arc Opaque stroke} def +/BoxFill {gsave Rec 1 setgray fill grestore} def +/Density { + /Fillden exch def + currentrgbcolor + /ColB exch def /ColG exch def /ColR exch def + /ColR ColR Fillden mul Fillden sub 1 add def + /ColG ColG Fillden mul Fillden sub 1 add def + /ColB ColB Fillden mul Fillden sub 1 add def + ColR ColG ColB setrgbcolor} def +/BoxColFill {gsave Rec PolyFill} def +/PolyFill {gsave Density fill grestore grestore} def +/h {rlineto rlineto rlineto gsave closepath fill grestore} bind def +% +% PostScript Level 1 Pattern Fill routine for rectangles +% Usage: x y w h s a XX PatternFill +% x,y = lower left corner of box to be filled +% w,h = width and height of box +% a = angle in degrees between lines and x-axis +% XX = 0/1 for no/yes cross-hatch +% +/PatternFill {gsave /PFa [ 9 2 roll ] def + PFa 0 get PFa 2 get 2 div add PFa 1 get PFa 3 get 2 div add translate + PFa 2 get -2 div PFa 3 get -2 div PFa 2 get PFa 3 get Rec + TransparentPatterns {} {gsave 1 setgray fill grestore} ifelse + clip + currentlinewidth 0.5 mul setlinewidth + /PFs PFa 2 get dup mul PFa 3 get dup mul add sqrt def + 0 0 M PFa 5 get rotate PFs -2 div dup translate + 0 1 PFs PFa 4 get div 1 add floor cvi + {PFa 4 get mul 0 M 0 PFs V} for + 0 PFa 6 get ne { + 0 1 PFs PFa 4 get div 1 add floor cvi + {PFa 4 get mul 0 2 1 roll M PFs 0 V} for + } if + stroke grestore} def +% +/languagelevel where + {pop languagelevel} {1} ifelse +dup 2 lt + {/InterpretLevel1 true def + /InterpretLevel3 false def} + {/InterpretLevel1 Level1 def + 2 gt + {/InterpretLevel3 Level3 def} + {/InterpretLevel3 false def} + ifelse } + ifelse +% +% PostScript level 2 pattern fill definitions +% +/Level2PatternFill { +/Tile8x8 {/PaintType 2 /PatternType 1 /TilingType 1 /BBox [0 0 8 8] /XStep 8 /YStep 8} + bind def +/KeepColor {currentrgbcolor [/Pattern /DeviceRGB] setcolorspace} bind def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 0 0 M 8 8 L 0 8 M 8 0 L stroke} +>> matrix makepattern +/Pat1 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 0 0 M 8 8 L 0 8 M 8 0 L stroke + 0 4 M 4 8 L 8 4 L 4 0 L 0 4 L stroke} +>> matrix makepattern +/Pat2 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 0 0 M 0 8 L + 8 8 L 8 0 L 0 0 L fill} +>> matrix makepattern +/Pat3 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop -4 8 M 8 -4 L + 0 12 M 12 0 L stroke} +>> matrix makepattern +/Pat4 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop -4 0 M 8 12 L + 0 -4 M 12 8 L stroke} +>> matrix makepattern +/Pat5 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop -2 8 M 4 -4 L + 0 12 M 8 -4 L 4 12 M 10 0 L stroke} +>> matrix makepattern +/Pat6 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop -2 0 M 4 12 L + 0 -4 M 8 12 L 4 -4 M 10 8 L stroke} +>> matrix makepattern +/Pat7 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 8 -2 M -4 4 L + 12 0 M -4 8 L 12 4 M 0 10 L stroke} +>> matrix makepattern +/Pat8 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 0 -2 M 12 4 L + -4 0 M 12 8 L -4 4 M 8 10 L stroke} +>> matrix makepattern +/Pat9 exch def +/Pattern1 {PatternBgnd KeepColor Pat1 setpattern} bind def +/Pattern2 {PatternBgnd KeepColor Pat2 setpattern} bind def +/Pattern3 {PatternBgnd KeepColor Pat3 setpattern} bind def +/Pattern4 {PatternBgnd KeepColor Landscape {Pat5} {Pat4} ifelse setpattern} bind def +/Pattern5 {PatternBgnd KeepColor Landscape {Pat4} {Pat5} ifelse setpattern} bind def +/Pattern6 {PatternBgnd KeepColor Landscape {Pat9} {Pat6} ifelse setpattern} bind def +/Pattern7 {PatternBgnd KeepColor Landscape {Pat8} {Pat7} ifelse setpattern} bind def +} def +% +% +%End of PostScript Level 2 code +% +/PatternBgnd { + TransparentPatterns {} {gsave 1 setgray fill grestore} ifelse +} def +% +% Substitute for Level 2 pattern fill codes with +% grayscale if Level 2 support is not selected. +% +/Level1PatternFill { +/Pattern1 {0.250 Density} bind def +/Pattern2 {0.500 Density} bind def +/Pattern3 {0.750 Density} bind def +/Pattern4 {0.125 Density} bind def +/Pattern5 {0.375 Density} bind def +/Pattern6 {0.625 Density} bind def +/Pattern7 {0.875 Density} bind def +} def +% +% Now test for support of Level 2 code +% +Level1 {Level1PatternFill} {Level2PatternFill} ifelse +% +/Symbol-Oblique /Symbol findfont [1 0 .167 1 0 0] makefont +dup length dict begin {1 index /FID eq {pop pop} {def} ifelse} forall +currentdict end definefont pop +% +/MFshow { + { dup 5 get 3 ge + { 5 get 3 eq {gsave} {grestore} ifelse } + {dup dup 0 get findfont exch 1 get scalefont setfont + [ currentpoint ] exch dup 2 get 0 exch R dup 5 get 2 ne {dup dup 6 + get exch 4 get {textshow} {stringwidth pop 0 R} ifelse }if dup 5 get 0 eq + {dup 3 get {2 get neg 0 exch R pop} {pop aload pop M} ifelse} {dup 5 + get 1 eq {dup 2 get exch dup 3 get exch 6 get stringwidth pop -2 div + dup 0 R} {dup 6 get stringwidth pop -2 div 0 R 6 get + textshow 2 index {aload pop M neg 3 -1 roll neg R pop pop} {pop pop pop + pop aload pop M} ifelse }ifelse }ifelse } + ifelse } + forall} def +/Gswidth {dup type /stringtype eq {stringwidth} {pop (n) stringwidth} ifelse} def +/MFwidth {0 exch { dup 5 get 3 ge { 5 get 3 eq { 0 } { pop } ifelse } + {dup 3 get{dup dup 0 get findfont exch 1 get scalefont setfont + 6 get Gswidth pop add} {pop} ifelse} ifelse} forall} def +/MLshow { currentpoint stroke M + 0 exch R + Blacktext {gsave 0 setgray MFshow grestore} {MFshow} ifelse } bind def +/MRshow { currentpoint stroke M + exch dup MFwidth neg 3 -1 roll R + Blacktext {gsave 0 setgray MFshow grestore} {MFshow} ifelse } bind def +/MCshow { currentpoint stroke M + exch dup MFwidth -2 div 3 -1 roll R + Blacktext {gsave 0 setgray MFshow grestore} {MFshow} ifelse } bind def +/XYsave { [( ) 1 2 true false 3 ()] } bind def +/XYrestore { [( ) 1 2 true false 4 ()] } bind def +Level1 SuppressPDFMark or +{} { +/SDict 10 dict def +systemdict /pdfmark known not { + userdict /pdfmark systemdict /cleartomark get put +} if +SDict begin [ + /Title (spec/tmp/histogram_plot.eps) + /Subject (gnuplot plot) + /Creator (gnuplot 5.0 patchlevel 5) +% /Producer (gnuplot) +% /Keywords () + /CreationDate (Fri Nov 22 22:11:02 2019) + /DOCINFO pdfmark +end +} ifelse +% +% Support for boxed text - Ethan A Merritt May 2005 +% +/InitTextBox { userdict /TBy2 3 -1 roll put userdict /TBx2 3 -1 roll put + userdict /TBy1 3 -1 roll put userdict /TBx1 3 -1 roll put + /Boxing true def } def +/ExtendTextBox { Boxing + { gsave dup false charpath pathbbox + dup TBy2 gt {userdict /TBy2 3 -1 roll put} {pop} ifelse + dup TBx2 gt {userdict /TBx2 3 -1 roll put} {pop} ifelse + dup TBy1 lt {userdict /TBy1 3 -1 roll put} {pop} ifelse + dup TBx1 lt {userdict /TBx1 3 -1 roll put} {pop} ifelse + grestore } if } def +/PopTextBox { newpath TBx1 TBxmargin sub TBy1 TBymargin sub M + TBx1 TBxmargin sub TBy2 TBymargin add L + TBx2 TBxmargin add TBy2 TBymargin add L + TBx2 TBxmargin add TBy1 TBymargin sub L closepath } def +/DrawTextBox { PopTextBox stroke /Boxing false def} def +/FillTextBox { gsave PopTextBox 1 1 1 setrgbcolor fill grestore /Boxing false def} def +0 0 0 0 InitTextBox +/TBxmargin 20 def +/TBymargin 20 def +/Boxing false def +/textshow { ExtendTextBox Gshow } def +% +% redundant definitions for compatibility with prologue.ps older than 5.0.2 +/LTB {BL [] LCb DL} def +/LTb {PL [] LCb DL} def +end +%%EndProlog +%%Page: 1 1 +gnudict begin +gsave +doclip +50 50 translate +0.050 0.050 scale +0 setgray +newpath +(Helvetica) findfont 140 scalefont setfont +BackgroundColor 0 lt 3 1 roll 0 lt exch 0 lt or or not {BackgroundColor C 1.000 0 0 7200.00 5040.00 BoxColFill} if +1.000 UL +LTb +LCb setrgbcolor +686 448 M +63 0 V +6198 0 R +-63 0 V +stroke +602 448 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 0)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 911 M +63 0 V +6198 0 R +-63 0 V +stroke +602 911 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 20)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 1375 M +63 0 V +6198 0 R +-63 0 V +stroke +602 1375 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 40)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 1838 M +63 0 V +6198 0 R +-63 0 V +stroke +602 1838 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 60)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 2302 M +63 0 V +6198 0 R +-63 0 V +stroke +602 2302 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 80)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 2765 M +63 0 V +6198 0 R +-63 0 V +stroke +602 2765 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 100)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 3229 M +63 0 V +6198 0 R +-63 0 V +stroke +602 3229 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 120)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 3692 M +63 0 V +6198 0 R +-63 0 V +stroke +602 3692 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 140)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 4156 M +63 0 V +6198 0 R +-63 0 V +stroke +602 4156 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 160)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 4619 M +63 0 V +6198 0 R +-63 0 V +stroke +602 4619 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 180)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 448 M +0 63 V +0 4108 R +0 -63 V +stroke +686 308 M +[ [(Helvetica) 140.0 0.0 true true 0 (-0.1)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +1938 448 M +0 63 V +0 4108 R +0 -63 V +stroke +1938 308 M +[ [(Helvetica) 140.0 0.0 true true 0 (-0.05)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +3190 448 M +0 63 V +0 4108 R +0 -63 V +stroke +3190 308 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 0)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +4443 448 M +0 63 V +0 4108 R +0 -63 V +stroke +4443 308 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 0.05)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +5695 448 M +0 63 V +0 4108 R +0 -63 V +stroke +5695 308 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 0.1)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +6947 448 M +0 63 V +0 4108 R +0 -63 V +stroke +6947 308 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 0.15)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +1.000 UL +LTB +LCb setrgbcolor +686 4619 N +686 448 L +6261 0 V +0 4171 V +-6261 0 V +Z stroke +1.000 UP +1.000 UL +LTb +LCb setrgbcolor +LCb setrgbcolor +112 2533 M +currentpoint gsave translate -270 rotate 0 0 moveto +[ [(Helvetica) 140.0 0.0 true true 0 (frequency)] +] -46.7 MCshow +grestore +LTb +LCb setrgbcolor +3816 98 M +[ [(Helvetica) 140.0 0.0 true true 0 (x)] +] -46.7 MCshow +LTb +LCb setrgbcolor +3816 4829 M +[ [(Helvetica) 140.0 0.0 true true 0 (Histogram)] +] -46.7 MCshow +% Begin plot #1 +1.000 UL +LTb +LCb setrgbcolor +LCb setrgbcolor +6296 4486 M +[ [(Helvetica) 140.0 0.0 true true 0 (smooth frequency)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +6380 4451 N +399 0 V +0 70 V +-399 0 V +0 -70 V +Z stroke +811 448 N +0 371 V +251 0 V +0 -371 V +-251 0 V +Z stroke +1062 448 N +0 209 V +250 0 V +0 -209 V +-250 0 V +Z stroke +1312 448 N +0 301 V +251 0 V +0 -301 V +-251 0 V +Z stroke +1563 448 N +0 255 V +250 0 V +0 -255 V +-250 0 V +Z stroke +1813 448 N +0 116 V +250 0 V +0 -116 V +-250 0 V +Z stroke +2063 448 N +0 209 V +251 0 V +0 -209 V +-251 0 V +Z stroke +2314 448 N +0 487 V +250 0 V +0 -487 V +-250 0 V +Z stroke +2564 448 N +0 417 V +251 0 V +0 -417 V +-251 0 V +Z stroke +2815 448 N +0 602 V +250 0 V +0 -602 V +-250 0 V +Z stroke +3065 448 N +0 3754 V +251 0 V +0 -3754 V +-251 0 V +Z stroke +3316 448 N +0 742 V +250 0 V +0 -742 V +-250 0 V +Z stroke +3566 448 N +0 440 V +251 0 V +0 -440 V +-251 0 V +Z stroke +3817 448 N +0 417 V +250 0 V +0 -417 V +-250 0 V +Z stroke +4067 448 N +0 301 V +250 0 V +0 -301 V +-250 0 V +Z stroke +4317 448 N +0 324 V +251 0 V +0 -324 V +-251 0 V +Z stroke +4568 448 N +0 278 V +250 0 V +0 -278 V +-250 0 V +Z stroke +4818 448 N +0 348 V +251 0 V +0 -348 V +-251 0 V +Z stroke +5069 448 N +0 394 V +250 0 V +0 -394 V +-250 0 V +Z stroke +5319 448 N +0 348 V +251 0 V +0 -348 V +-251 0 V +Z stroke +5570 448 N +0 463 V +250 0 V +0 -463 V +-250 0 V +Z stroke +5820 448 N +0 834 V +125 0 V +0 -834 V +-125 0 V +Z stroke +% End plot #1 +2.000 UL +LTb +LCb setrgbcolor +1.000 UL +LTB +LCb setrgbcolor +686 4619 N +686 448 L +6261 0 V +0 4171 V +-6261 0 V +Z stroke +1.000 UP +1.000 UL +LTb +LCb setrgbcolor +stroke +grestore +end +showpage +%%Trailer +%%DocumentFonts: Helvetica diff --git a/spec/integration/histtest_spec.rb b/spec/integration/histtest_spec.rb index 47d7aea..2dda5f3 100644 --- a/spec/integration/histtest_spec.rb +++ b/spec/integration/histtest_spec.rb @@ -12,8 +12,10 @@ before do path = file_path + RandomGenerator.seed(0.17) + collection = (0..500).collect do |_v| - (rand()-0.5)**3 + (RandomGenerator.rand-0.5)**3 end Gnuplot.open do |gp| diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 051338c..38530b9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -20,6 +20,10 @@ require "gnuplot" +support_files = File.expand_path('spec/support/**/*.rb') + +Dir[support_files].sort.each { |file| require file } + RSpec.configure do |config| # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest diff --git a/spec/support/models/random_generator.rb b/spec/support/models/random_generator.rb new file mode 100644 index 0000000..96e752e --- /dev/null +++ b/spec/support/models/random_generator.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class RandomGenerator + KAPA = 3.95578 + + class << self + def rand + @rand ||= Random.rand + + @rand = KAPA * @rand * (1 - @rand) + end + + def seed(value) + @rand = value.abs % 1 + @rand = nil if @rand == 0 + end + end +end From 093b6bdee6dc62eef8b345faa2be03d8e5b83354 Mon Sep 17 00:00:00 2001 From: darthjee Date: Fri, 22 Nov 2019 23:19:25 +0100 Subject: [PATCH 35/55] Add sin wave spec --- spec/fixtures/plots/sin_wave_plot.eps | 857 ++++++++++++++++++++++++++ spec/integration/histtest_spec.rb | 2 +- spec/integration/multtest_spec.rb | 57 ++ test/multtest.rb | 10 +- 4 files changed, 920 insertions(+), 6 deletions(-) create mode 100644 spec/fixtures/plots/sin_wave_plot.eps create mode 100644 spec/integration/multtest_spec.rb diff --git a/spec/fixtures/plots/sin_wave_plot.eps b/spec/fixtures/plots/sin_wave_plot.eps new file mode 100644 index 0000000..4dea1f4 --- /dev/null +++ b/spec/fixtures/plots/sin_wave_plot.eps @@ -0,0 +1,857 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: spec/tmp/sin_wave_plot.eps +%%Creator: gnuplot 5.0 patchlevel 5 +%%CreationDate: Fri Nov 22 22:17:59 2019 +%%DocumentFonts: (atend) +%%BoundingBox: 50 50 410 302 +%%EndComments +%%BeginProlog +/gnudict 256 dict def +gnudict begin +% +% The following true/false flags may be edited by hand if desired. +% The unit line width and grayscale image gamma correction may also be changed. +% +/Color false def +/Blacktext false def +/Solid false def +/Dashlength 1 def +/Landscape false def +/Level1 false def +/Level3 false def +/Rounded false def +/ClipToBoundingBox false def +/SuppressPDFMark false def +/TransparentPatterns false def +/gnulinewidth 5.000 def +/userlinewidth gnulinewidth def +/Gamma 1.0 def +/BackgroundColor {-1.000 -1.000 -1.000} def +% +/vshift -46 def +/dl1 { + 10.0 Dashlength userlinewidth gnulinewidth div mul mul mul + Rounded { currentlinewidth 0.75 mul sub dup 0 le { pop 0.01 } if } if +} def +/dl2 { + 10.0 Dashlength userlinewidth gnulinewidth div mul mul mul + Rounded { currentlinewidth 0.75 mul add } if +} def +/hpt_ 31.5 def +/vpt_ 31.5 def +/hpt hpt_ def +/vpt vpt_ def +/doclip { + ClipToBoundingBox { + newpath 50 50 moveto 410 50 lineto 410 302 lineto 50 302 lineto closepath + clip + } if +} def +% +% Gnuplot Prolog Version 5.1 (Oct 2015) +% +%/SuppressPDFMark true def +% +/M {moveto} bind def +/L {lineto} bind def +/R {rmoveto} bind def +/V {rlineto} bind def +/N {newpath moveto} bind def +/Z {closepath} bind def +/C {setrgbcolor} bind def +/f {rlineto fill} bind def +/g {setgray} bind def +/Gshow {show} def % May be redefined later in the file to support UTF-8 +/vpt2 vpt 2 mul def +/hpt2 hpt 2 mul def +/Lshow {currentpoint stroke M 0 vshift R + Blacktext {gsave 0 setgray textshow grestore} {textshow} ifelse} def +/Rshow {currentpoint stroke M dup stringwidth pop neg vshift R + Blacktext {gsave 0 setgray textshow grestore} {textshow} ifelse} def +/Cshow {currentpoint stroke M dup stringwidth pop -2 div vshift R + Blacktext {gsave 0 setgray textshow grestore} {textshow} ifelse} def +/UP {dup vpt_ mul /vpt exch def hpt_ mul /hpt exch def + /hpt2 hpt 2 mul def /vpt2 vpt 2 mul def} def +/DL {Color {setrgbcolor Solid {pop []} if 0 setdash} + {pop pop pop 0 setgray Solid {pop []} if 0 setdash} ifelse} def +/BL {stroke userlinewidth 2 mul setlinewidth + Rounded {1 setlinejoin 1 setlinecap} if} def +/AL {stroke userlinewidth 2 div setlinewidth + Rounded {1 setlinejoin 1 setlinecap} if} def +/UL {dup gnulinewidth mul /userlinewidth exch def + dup 1 lt {pop 1} if 10 mul /udl exch def} def +/PL {stroke userlinewidth setlinewidth + Rounded {1 setlinejoin 1 setlinecap} if} def +3.8 setmiterlimit +% Classic Line colors (version 5.0) +/LCw {1 1 1} def +/LCb {0 0 0} def +/LCa {0 0 0} def +/LC0 {1 0 0} def +/LC1 {0 1 0} def +/LC2 {0 0 1} def +/LC3 {1 0 1} def +/LC4 {0 1 1} def +/LC5 {1 1 0} def +/LC6 {0 0 0} def +/LC7 {1 0.3 0} def +/LC8 {0.5 0.5 0.5} def +% Default dash patterns (version 5.0) +/LTB {BL [] LCb DL} def +/LTw {PL [] 1 setgray} def +/LTb {PL [] LCb DL} def +/LTa {AL [1 udl mul 2 udl mul] 0 setdash LCa setrgbcolor} def +/LT0 {PL [] LC0 DL} def +/LT1 {PL [2 dl1 3 dl2] LC1 DL} def +/LT2 {PL [1 dl1 1.5 dl2] LC2 DL} def +/LT3 {PL [6 dl1 2 dl2 1 dl1 2 dl2] LC3 DL} def +/LT4 {PL [1 dl1 2 dl2 6 dl1 2 dl2 1 dl1 2 dl2] LC4 DL} def +/LT5 {PL [4 dl1 2 dl2] LC5 DL} def +/LT6 {PL [1.5 dl1 1.5 dl2 1.5 dl1 1.5 dl2 1.5 dl1 6 dl2] LC6 DL} def +/LT7 {PL [3 dl1 3 dl2 1 dl1 3 dl2] LC7 DL} def +/LT8 {PL [2 dl1 2 dl2 2 dl1 6 dl2] LC8 DL} def +/SL {[] 0 setdash} def +/Pnt {stroke [] 0 setdash gsave 1 setlinecap M 0 0 V stroke grestore} def +/Dia {stroke [] 0 setdash 2 copy vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V closepath stroke + Pnt} def +/Pls {stroke [] 0 setdash vpt sub M 0 vpt2 V + currentpoint stroke M + hpt neg vpt neg R hpt2 0 V stroke + } def +/Box {stroke [] 0 setdash 2 copy exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V closepath stroke + Pnt} def +/Crs {stroke [] 0 setdash exch hpt sub exch vpt add M + hpt2 vpt2 neg V currentpoint stroke M + hpt2 neg 0 R hpt2 vpt2 V stroke} def +/TriU {stroke [] 0 setdash 2 copy vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V closepath stroke + Pnt} def +/Star {2 copy Pls Crs} def +/BoxF {stroke [] 0 setdash exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V closepath fill} def +/TriUF {stroke [] 0 setdash vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V closepath fill} def +/TriD {stroke [] 0 setdash 2 copy vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V closepath stroke + Pnt} def +/TriDF {stroke [] 0 setdash vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V closepath fill} def +/DiaF {stroke [] 0 setdash vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V closepath fill} def +/Pent {stroke [] 0 setdash 2 copy gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + closepath stroke grestore Pnt} def +/PentF {stroke [] 0 setdash gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + closepath fill grestore} def +/Circle {stroke [] 0 setdash 2 copy + hpt 0 360 arc stroke Pnt} def +/CircleF {stroke [] 0 setdash hpt 0 360 arc fill} def +/C0 {BL [] 0 setdash 2 copy moveto vpt 90 450 arc} bind def +/C1 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 90 arc closepath fill + vpt 0 360 arc closepath} bind def +/C2 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 90 180 arc closepath fill + vpt 0 360 arc closepath} bind def +/C3 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 180 arc closepath fill + vpt 0 360 arc closepath} bind def +/C4 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 180 270 arc closepath fill + vpt 0 360 arc closepath} bind def +/C5 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 90 arc + 2 copy moveto + 2 copy vpt 180 270 arc closepath fill + vpt 0 360 arc} bind def +/C6 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 90 270 arc closepath fill + vpt 0 360 arc closepath} bind def +/C7 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 270 arc closepath fill + vpt 0 360 arc closepath} bind def +/C8 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 270 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/C9 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 270 450 arc closepath fill + vpt 0 360 arc closepath} bind def +/C10 {BL [] 0 setdash 2 copy 2 copy moveto vpt 270 360 arc closepath fill + 2 copy moveto + 2 copy vpt 90 180 arc closepath fill + vpt 0 360 arc closepath} bind def +/C11 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 180 arc closepath fill + 2 copy moveto + 2 copy vpt 270 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/C12 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 180 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/C13 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 90 arc closepath fill + 2 copy moveto + 2 copy vpt 180 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/C14 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 90 360 arc closepath fill + vpt 0 360 arc} bind def +/C15 {BL [] 0 setdash 2 copy vpt 0 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/Rec {newpath 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto + neg 0 rlineto closepath} bind def +/Square {dup Rec} bind def +/Bsquare {vpt sub exch vpt sub exch vpt2 Square} bind def +/S0 {BL [] 0 setdash 2 copy moveto 0 vpt rlineto BL Bsquare} bind def +/S1 {BL [] 0 setdash 2 copy vpt Square fill Bsquare} bind def +/S2 {BL [] 0 setdash 2 copy exch vpt sub exch vpt Square fill Bsquare} bind def +/S3 {BL [] 0 setdash 2 copy exch vpt sub exch vpt2 vpt Rec fill Bsquare} bind def +/S4 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt Square fill Bsquare} bind def +/S5 {BL [] 0 setdash 2 copy 2 copy vpt Square fill + exch vpt sub exch vpt sub vpt Square fill Bsquare} bind def +/S6 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill Bsquare} bind def +/S7 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill + 2 copy vpt Square fill Bsquare} bind def +/S8 {BL [] 0 setdash 2 copy vpt sub vpt Square fill Bsquare} bind def +/S9 {BL [] 0 setdash 2 copy vpt sub vpt vpt2 Rec fill Bsquare} bind def +/S10 {BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt Square fill + Bsquare} bind def +/S11 {BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt2 vpt Rec fill + Bsquare} bind def +/S12 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill Bsquare} bind def +/S13 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill + 2 copy vpt Square fill Bsquare} bind def +/S14 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill + 2 copy exch vpt sub exch vpt Square fill Bsquare} bind def +/S15 {BL [] 0 setdash 2 copy Bsquare fill Bsquare} bind def +/D0 {gsave translate 45 rotate 0 0 S0 stroke grestore} bind def +/D1 {gsave translate 45 rotate 0 0 S1 stroke grestore} bind def +/D2 {gsave translate 45 rotate 0 0 S2 stroke grestore} bind def +/D3 {gsave translate 45 rotate 0 0 S3 stroke grestore} bind def +/D4 {gsave translate 45 rotate 0 0 S4 stroke grestore} bind def +/D5 {gsave translate 45 rotate 0 0 S5 stroke grestore} bind def +/D6 {gsave translate 45 rotate 0 0 S6 stroke grestore} bind def +/D7 {gsave translate 45 rotate 0 0 S7 stroke grestore} bind def +/D8 {gsave translate 45 rotate 0 0 S8 stroke grestore} bind def +/D9 {gsave translate 45 rotate 0 0 S9 stroke grestore} bind def +/D10 {gsave translate 45 rotate 0 0 S10 stroke grestore} bind def +/D11 {gsave translate 45 rotate 0 0 S11 stroke grestore} bind def +/D12 {gsave translate 45 rotate 0 0 S12 stroke grestore} bind def +/D13 {gsave translate 45 rotate 0 0 S13 stroke grestore} bind def +/D14 {gsave translate 45 rotate 0 0 S14 stroke grestore} bind def +/D15 {gsave translate 45 rotate 0 0 S15 stroke grestore} bind def +/DiaE {stroke [] 0 setdash vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V closepath stroke} def +/BoxE {stroke [] 0 setdash exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V closepath stroke} def +/TriUE {stroke [] 0 setdash vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V closepath stroke} def +/TriDE {stroke [] 0 setdash vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V closepath stroke} def +/PentE {stroke [] 0 setdash gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + closepath stroke grestore} def +/CircE {stroke [] 0 setdash + hpt 0 360 arc stroke} def +/Opaque {gsave closepath 1 setgray fill grestore 0 setgray closepath} def +/DiaW {stroke [] 0 setdash vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V Opaque stroke} def +/BoxW {stroke [] 0 setdash exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V Opaque stroke} def +/TriUW {stroke [] 0 setdash vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V Opaque stroke} def +/TriDW {stroke [] 0 setdash vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V Opaque stroke} def +/PentW {stroke [] 0 setdash gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + Opaque stroke grestore} def +/CircW {stroke [] 0 setdash + hpt 0 360 arc Opaque stroke} def +/BoxFill {gsave Rec 1 setgray fill grestore} def +/Density { + /Fillden exch def + currentrgbcolor + /ColB exch def /ColG exch def /ColR exch def + /ColR ColR Fillden mul Fillden sub 1 add def + /ColG ColG Fillden mul Fillden sub 1 add def + /ColB ColB Fillden mul Fillden sub 1 add def + ColR ColG ColB setrgbcolor} def +/BoxColFill {gsave Rec PolyFill} def +/PolyFill {gsave Density fill grestore grestore} def +/h {rlineto rlineto rlineto gsave closepath fill grestore} bind def +% +% PostScript Level 1 Pattern Fill routine for rectangles +% Usage: x y w h s a XX PatternFill +% x,y = lower left corner of box to be filled +% w,h = width and height of box +% a = angle in degrees between lines and x-axis +% XX = 0/1 for no/yes cross-hatch +% +/PatternFill {gsave /PFa [ 9 2 roll ] def + PFa 0 get PFa 2 get 2 div add PFa 1 get PFa 3 get 2 div add translate + PFa 2 get -2 div PFa 3 get -2 div PFa 2 get PFa 3 get Rec + TransparentPatterns {} {gsave 1 setgray fill grestore} ifelse + clip + currentlinewidth 0.5 mul setlinewidth + /PFs PFa 2 get dup mul PFa 3 get dup mul add sqrt def + 0 0 M PFa 5 get rotate PFs -2 div dup translate + 0 1 PFs PFa 4 get div 1 add floor cvi + {PFa 4 get mul 0 M 0 PFs V} for + 0 PFa 6 get ne { + 0 1 PFs PFa 4 get div 1 add floor cvi + {PFa 4 get mul 0 2 1 roll M PFs 0 V} for + } if + stroke grestore} def +% +/languagelevel where + {pop languagelevel} {1} ifelse +dup 2 lt + {/InterpretLevel1 true def + /InterpretLevel3 false def} + {/InterpretLevel1 Level1 def + 2 gt + {/InterpretLevel3 Level3 def} + {/InterpretLevel3 false def} + ifelse } + ifelse +% +% PostScript level 2 pattern fill definitions +% +/Level2PatternFill { +/Tile8x8 {/PaintType 2 /PatternType 1 /TilingType 1 /BBox [0 0 8 8] /XStep 8 /YStep 8} + bind def +/KeepColor {currentrgbcolor [/Pattern /DeviceRGB] setcolorspace} bind def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 0 0 M 8 8 L 0 8 M 8 0 L stroke} +>> matrix makepattern +/Pat1 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 0 0 M 8 8 L 0 8 M 8 0 L stroke + 0 4 M 4 8 L 8 4 L 4 0 L 0 4 L stroke} +>> matrix makepattern +/Pat2 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 0 0 M 0 8 L + 8 8 L 8 0 L 0 0 L fill} +>> matrix makepattern +/Pat3 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop -4 8 M 8 -4 L + 0 12 M 12 0 L stroke} +>> matrix makepattern +/Pat4 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop -4 0 M 8 12 L + 0 -4 M 12 8 L stroke} +>> matrix makepattern +/Pat5 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop -2 8 M 4 -4 L + 0 12 M 8 -4 L 4 12 M 10 0 L stroke} +>> matrix makepattern +/Pat6 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop -2 0 M 4 12 L + 0 -4 M 8 12 L 4 -4 M 10 8 L stroke} +>> matrix makepattern +/Pat7 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 8 -2 M -4 4 L + 12 0 M -4 8 L 12 4 M 0 10 L stroke} +>> matrix makepattern +/Pat8 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 0 -2 M 12 4 L + -4 0 M 12 8 L -4 4 M 8 10 L stroke} +>> matrix makepattern +/Pat9 exch def +/Pattern1 {PatternBgnd KeepColor Pat1 setpattern} bind def +/Pattern2 {PatternBgnd KeepColor Pat2 setpattern} bind def +/Pattern3 {PatternBgnd KeepColor Pat3 setpattern} bind def +/Pattern4 {PatternBgnd KeepColor Landscape {Pat5} {Pat4} ifelse setpattern} bind def +/Pattern5 {PatternBgnd KeepColor Landscape {Pat4} {Pat5} ifelse setpattern} bind def +/Pattern6 {PatternBgnd KeepColor Landscape {Pat9} {Pat6} ifelse setpattern} bind def +/Pattern7 {PatternBgnd KeepColor Landscape {Pat8} {Pat7} ifelse setpattern} bind def +} def +% +% +%End of PostScript Level 2 code +% +/PatternBgnd { + TransparentPatterns {} {gsave 1 setgray fill grestore} ifelse +} def +% +% Substitute for Level 2 pattern fill codes with +% grayscale if Level 2 support is not selected. +% +/Level1PatternFill { +/Pattern1 {0.250 Density} bind def +/Pattern2 {0.500 Density} bind def +/Pattern3 {0.750 Density} bind def +/Pattern4 {0.125 Density} bind def +/Pattern5 {0.375 Density} bind def +/Pattern6 {0.625 Density} bind def +/Pattern7 {0.875 Density} bind def +} def +% +% Now test for support of Level 2 code +% +Level1 {Level1PatternFill} {Level2PatternFill} ifelse +% +/Symbol-Oblique /Symbol findfont [1 0 .167 1 0 0] makefont +dup length dict begin {1 index /FID eq {pop pop} {def} ifelse} forall +currentdict end definefont pop +% +/MFshow { + { dup 5 get 3 ge + { 5 get 3 eq {gsave} {grestore} ifelse } + {dup dup 0 get findfont exch 1 get scalefont setfont + [ currentpoint ] exch dup 2 get 0 exch R dup 5 get 2 ne {dup dup 6 + get exch 4 get {textshow} {stringwidth pop 0 R} ifelse }if dup 5 get 0 eq + {dup 3 get {2 get neg 0 exch R pop} {pop aload pop M} ifelse} {dup 5 + get 1 eq {dup 2 get exch dup 3 get exch 6 get stringwidth pop -2 div + dup 0 R} {dup 6 get stringwidth pop -2 div 0 R 6 get + textshow 2 index {aload pop M neg 3 -1 roll neg R pop pop} {pop pop pop + pop aload pop M} ifelse }ifelse }ifelse } + ifelse } + forall} def +/Gswidth {dup type /stringtype eq {stringwidth} {pop (n) stringwidth} ifelse} def +/MFwidth {0 exch { dup 5 get 3 ge { 5 get 3 eq { 0 } { pop } ifelse } + {dup 3 get{dup dup 0 get findfont exch 1 get scalefont setfont + 6 get Gswidth pop add} {pop} ifelse} ifelse} forall} def +/MLshow { currentpoint stroke M + 0 exch R + Blacktext {gsave 0 setgray MFshow grestore} {MFshow} ifelse } bind def +/MRshow { currentpoint stroke M + exch dup MFwidth neg 3 -1 roll R + Blacktext {gsave 0 setgray MFshow grestore} {MFshow} ifelse } bind def +/MCshow { currentpoint stroke M + exch dup MFwidth -2 div 3 -1 roll R + Blacktext {gsave 0 setgray MFshow grestore} {MFshow} ifelse } bind def +/XYsave { [( ) 1 2 true false 3 ()] } bind def +/XYrestore { [( ) 1 2 true false 4 ()] } bind def +Level1 SuppressPDFMark or +{} { +/SDict 10 dict def +systemdict /pdfmark known not { + userdict /pdfmark systemdict /cleartomark get put +} if +SDict begin [ + /Title (spec/tmp/sin_wave_plot.eps) + /Subject (gnuplot plot) + /Creator (gnuplot 5.0 patchlevel 5) +% /Producer (gnuplot) +% /Keywords () + /CreationDate (Fri Nov 22 22:17:59 2019) + /DOCINFO pdfmark +end +} ifelse +% +% Support for boxed text - Ethan A Merritt May 2005 +% +/InitTextBox { userdict /TBy2 3 -1 roll put userdict /TBx2 3 -1 roll put + userdict /TBy1 3 -1 roll put userdict /TBx1 3 -1 roll put + /Boxing true def } def +/ExtendTextBox { Boxing + { gsave dup false charpath pathbbox + dup TBy2 gt {userdict /TBy2 3 -1 roll put} {pop} ifelse + dup TBx2 gt {userdict /TBx2 3 -1 roll put} {pop} ifelse + dup TBy1 lt {userdict /TBy1 3 -1 roll put} {pop} ifelse + dup TBx1 lt {userdict /TBx1 3 -1 roll put} {pop} ifelse + grestore } if } def +/PopTextBox { newpath TBx1 TBxmargin sub TBy1 TBymargin sub M + TBx1 TBxmargin sub TBy2 TBymargin add L + TBx2 TBxmargin add TBy2 TBymargin add L + TBx2 TBxmargin add TBy1 TBymargin sub L closepath } def +/DrawTextBox { PopTextBox stroke /Boxing false def} def +/FillTextBox { gsave PopTextBox 1 1 1 setrgbcolor fill grestore /Boxing false def} def +0 0 0 0 InitTextBox +/TBxmargin 20 def +/TBymargin 20 def +/Boxing false def +/textshow { ExtendTextBox Gshow } def +% +% redundant definitions for compatibility with prologue.ps older than 5.0.2 +/LTB {BL [] LCb DL} def +/LTb {PL [] LCb DL} def +end +%%EndProlog +%%Page: 1 1 +gnudict begin +gsave +doclip +50 50 translate +0.050 0.050 scale +0 setgray +newpath +(Helvetica) findfont 140 scalefont setfont +BackgroundColor 0 lt 3 1 roll 0 lt exch 0 lt or or not {BackgroundColor C 1.000 0 0 7200.00 5040.00 BoxColFill} if +1.000 UL +LTb +LCb setrgbcolor +686 448 M +63 0 V +6198 0 R +-63 0 V +stroke +602 448 M +[ [(Helvetica) 140.0 0.0 true true 0 (-20)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 1143 M +63 0 V +6198 0 R +-63 0 V +stroke +602 1143 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 0)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 1838 M +63 0 V +6198 0 R +-63 0 V +stroke +602 1838 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 20)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 2534 M +63 0 V +6198 0 R +-63 0 V +stroke +602 2534 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 40)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 3229 M +63 0 V +6198 0 R +-63 0 V +stroke +602 3229 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 60)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 3924 M +63 0 V +6198 0 R +-63 0 V +stroke +602 3924 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 80)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 4619 M +63 0 V +6198 0 R +-63 0 V +stroke +602 4619 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 100)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 448 M +0 63 V +0 4108 R +0 -63 V +stroke +686 308 M +[ [(Helvetica) 140.0 0.0 true true 0 (-10)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +2251 448 M +0 63 V +0 4108 R +0 -63 V +stroke +2251 308 M +[ [(Helvetica) 140.0 0.0 true true 0 (-5)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +3817 448 M +0 63 V +0 4108 R +0 -63 V +stroke +3817 308 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 0)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +5382 448 M +0 63 V +0 4108 R +0 -63 V +stroke +5382 308 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 5)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +6947 448 M +0 63 V +0 4108 R +0 -63 V +stroke +6947 308 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 10)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +1.000 UL +LTB +LCb setrgbcolor +686 4619 N +686 448 L +6261 0 V +0 4171 V +-6261 0 V +Z stroke +1.000 UP +1.000 UL +LTb +LCb setrgbcolor +LCb setrgbcolor +112 2533 M +currentpoint gsave translate -270 rotate 0 0 moveto +[ [(Helvetica) 140.0 0.0 true true 0 (x)] +] -46.7 MCshow +grestore +LTb +LCb setrgbcolor +3816 98 M +[ [(Helvetica) 140.0 0.0 true true 0 (sin\(x\))] +] -46.7 MCshow +LTb +LCb setrgbcolor +3816 4829 M +[ [(Helvetica) 140.0 0.0 true true 0 (Sin Wave Example)] +] -46.7 MCshow +% Begin plot #1 +4.000 UL +LTb +LCb setrgbcolor +LCb setrgbcolor +6296 4486 M +[ [(Helvetica) 140.0 0.0 true true 0 (String function)] +] -46.7 MRshow +4.000 UL +LTb +LCb setrgbcolor +6380 4486 M +399 0 V +686 1162 M +63 -6 V +63 -7 V +64 -7 V +63 -7 V +63 -6 V +63 -7 V +64 -5 V +63 -4 V +63 -3 V +63 -1 V +64 0 V +63 1 V +63 2 V +63 4 V +64 5 V +63 6 V +63 6 V +63 7 V +64 7 V +63 7 V +63 7 V +63 5 V +64 5 V +63 4 V +63 2 V +63 1 V +64 -1 V +63 -1 V +63 -4 V +63 -4 V +64 -5 V +63 -6 V +63 -7 V +63 -7 V +63 -7 V +64 -7 V +63 -6 V +63 -5 V +63 -4 V +64 -4 V +63 -1 V +63 -1 V +63 2 V +64 2 V +63 4 V +63 5 V +63 5 V +64 7 V +63 7 V +63 7 V +63 7 V +64 6 V +63 6 V +63 5 V +63 3 V +64 3 V +63 1 V +63 0 V +63 -2 V +64 -3 V +63 -4 V +63 -6 V +63 -6 V +64 -7 V +63 -6 V +63 -7 V +63 -7 V +63 -6 V +64 -6 V +63 -4 V +63 -3 V +63 -2 V +64 -1 V +63 1 V +63 3 V +63 3 V +64 5 V +63 6 V +63 6 V +63 7 V +64 7 V +63 7 V +63 6 V +63 6 V +64 5 V +63 4 V +63 3 V +63 1 V +64 0 V +63 -2 V +63 -3 V +63 -4 V +64 -5 V +63 -6 V +63 -7 V +63 -7 V +64 -7 V +63 -7 V +63 -6 V +% End plot #1 +% Begin plot #2 +1.000 UP +stroke +1.000 UL +LTb +LT1 +LCb setrgbcolor +LCb setrgbcolor +6296 4346 M +[ [(Helvetica) 140.0 0.0 true true 0 (Array data)] +] -46.7 MRshow +1.000 UP +1.000 UL +LTb +LT1 +LCb setrgbcolor +6380 4346 M +399 0 V +3817 1143 M +313 35 V +313 104 V +313 174 V +313 243 V +313 313 V +313 382 V +313 452 V +313 522 V +313 591 V +313 660 V +3817 1143 Pls +4130 1178 Pls +4443 1282 Pls +4756 1456 Pls +5069 1699 Pls +5382 2012 Pls +5695 2394 Pls +6008 2846 Pls +6321 3368 Pls +6634 3959 Pls +6947 4619 Pls +6579 4346 Pls +% End plot #2 +2.000 UL +LTb +LCb setrgbcolor +1.000 UL +LTB +LCb setrgbcolor +686 4619 N +686 448 L +6261 0 V +0 4171 V +-6261 0 V +Z stroke +1.000 UP +1.000 UL +LTb +LCb setrgbcolor +stroke +grestore +end +showpage +%%Trailer +%%DocumentFonts: Helvetica diff --git a/spec/integration/histtest_spec.rb b/spec/integration/histtest_spec.rb index 2dda5f3..3cc98fa 100644 --- a/spec/integration/histtest_spec.rb +++ b/spec/integration/histtest_spec.rb @@ -14,7 +14,7 @@ path = file_path RandomGenerator.seed(0.17) - collection = (0..500).collect do |_v| + collection = (0..500).collect do (RandomGenerator.rand-0.5)**3 end diff --git a/spec/integration/multtest_spec.rb b/spec/integration/multtest_spec.rb new file mode 100644 index 0000000..41d27d0 --- /dev/null +++ b/spec/integration/multtest_spec.rb @@ -0,0 +1,57 @@ +describe "Sin Wave Plot Example" do + let(:file_path) { 'spec/tmp/sin_wave_plot.eps' } + let(:fixture_path) { 'spec/fixtures/plots/sin_wave_plot.eps' } + + let(:file_content) do + File.read(file_path).gsub(/CreationDate.*/, "") + end + + let(:fixture_content) do + File.read(fixture_path).gsub(/CreationDate.*/, "") + end + + before do + path = file_path + + Gnuplot.open do |gp| + Gnuplot::Plot.new( gp ) do |plot| + + plot.xrange "[-10:10]" + plot.title "Sin Wave Example" + plot.ylabel "x" + plot.xlabel "sin(x)" + + plot.term "postscript eps" + plot.output path + + x = (0..50).collect { |v| v.to_f } + y = x.collect { |v| v ** 2 } + + plot.data = [ + Gnuplot::DataSet.new( "sin(x)" ) { |ds| + ds.with = "lines" + ds.title = "String function" + ds.linewidth = 4 + }, + + Gnuplot::DataSet.new( [x, y] ) { |ds| + ds.with = "linespoints" + ds.title = "Array data" + } + ] + + end + + end + + end + + after do + File.delete(file_path) + end + + it "plots expected file" do + expect(file_content).to eq(fixture_content) + end +end + diff --git a/test/multtest.rb b/test/multtest.rb index 3bf4983..dcd06c1 100644 --- a/test/multtest.rb +++ b/test/multtest.rb @@ -14,14 +14,14 @@ plot.data = [ Gnuplot::DataSet.new( "sin(x)" ) { |ds| - ds.with = "lines" - ds.title = "String function" - ds.linewidth = 4 + ds.with = "lines" + ds.title = "String function" + ds.linewidth = 4 }, Gnuplot::DataSet.new( [x, y] ) { |ds| - ds.with = "linespoints" - ds.title = "Array data" + ds.with = "linespoints" + ds.title = "Array data" } ] From 15e80d890f08e9b7d78321657528af5a4ccacfc6 Mon Sep 17 00:00:00 2001 From: darthjee Date: Fri, 22 Nov 2019 23:28:26 +0100 Subject: [PATCH 36/55] Rename test --- .../plots/{sin_wave_plot.eps => multtest_plot.eps} | 8 ++++---- spec/integration/multtest_spec.rb | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) rename spec/fixtures/plots/{sin_wave_plot.eps => multtest_plot.eps} (99%) diff --git a/spec/fixtures/plots/sin_wave_plot.eps b/spec/fixtures/plots/multtest_plot.eps similarity index 99% rename from spec/fixtures/plots/sin_wave_plot.eps rename to spec/fixtures/plots/multtest_plot.eps index 4dea1f4..7575c79 100644 --- a/spec/fixtures/plots/sin_wave_plot.eps +++ b/spec/fixtures/plots/multtest_plot.eps @@ -1,7 +1,7 @@ %!PS-Adobe-2.0 EPSF-2.0 -%%Title: spec/tmp/sin_wave_plot.eps +%%Title: spec/tmp/multtest_plot.eps %%Creator: gnuplot 5.0 patchlevel 5 -%%CreationDate: Fri Nov 22 22:17:59 2019 +%%CreationDate: Fri Nov 22 22:28:48 2019 %%DocumentFonts: (atend) %%BoundingBox: 50 50 410 302 %%EndComments @@ -464,12 +464,12 @@ systemdict /pdfmark known not { userdict /pdfmark systemdict /cleartomark get put } if SDict begin [ - /Title (spec/tmp/sin_wave_plot.eps) + /Title (spec/tmp/multtest_plot.eps) /Subject (gnuplot plot) /Creator (gnuplot 5.0 patchlevel 5) % /Producer (gnuplot) % /Keywords () - /CreationDate (Fri Nov 22 22:17:59 2019) + /CreationDate (Fri Nov 22 22:28:48 2019) /DOCINFO pdfmark end } ifelse diff --git a/spec/integration/multtest_spec.rb b/spec/integration/multtest_spec.rb index 41d27d0..31c5923 100644 --- a/spec/integration/multtest_spec.rb +++ b/spec/integration/multtest_spec.rb @@ -1,6 +1,6 @@ -describe "Sin Wave Plot Example" do - let(:file_path) { 'spec/tmp/sin_wave_plot.eps' } - let(:fixture_path) { 'spec/fixtures/plots/sin_wave_plot.eps' } +describe "Multtest Plot Example" do + let(:file_path) { 'spec/tmp/multtest_plot.eps' } + let(:fixture_path) { 'spec/fixtures/plots/multtest_plot.eps' } let(:file_content) do File.read(file_path).gsub(/CreationDate.*/, "") @@ -47,7 +47,7 @@ end after do - File.delete(file_path) + File.delete(file_path) end it "plots expected file" do From 53369f7669c702ea9913614ad8144ac541828fbf Mon Sep 17 00:00:00 2001 From: darthjee Date: Fri, 22 Nov 2019 23:31:22 +0100 Subject: [PATCH 37/55] Add sinwave spec --- spec/fixtures/plots/sin_wave_plot.eps | 862 ++++++++++++++++++++++++++ spec/integration/sinwave_spec.rb | 46 ++ 2 files changed, 908 insertions(+) create mode 100644 spec/fixtures/plots/sin_wave_plot.eps create mode 100644 spec/integration/sinwave_spec.rb diff --git a/spec/fixtures/plots/sin_wave_plot.eps b/spec/fixtures/plots/sin_wave_plot.eps new file mode 100644 index 0000000..f30514a --- /dev/null +++ b/spec/fixtures/plots/sin_wave_plot.eps @@ -0,0 +1,862 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: spec/tmp/sin_wave_plot.eps +%%Creator: gnuplot 5.0 patchlevel 5 +%%CreationDate: Fri Nov 22 22:30:52 2019 +%%DocumentFonts: (atend) +%%BoundingBox: 50 50 410 302 +%%EndComments +%%BeginProlog +/gnudict 256 dict def +gnudict begin +% +% The following true/false flags may be edited by hand if desired. +% The unit line width and grayscale image gamma correction may also be changed. +% +/Color false def +/Blacktext false def +/Solid false def +/Dashlength 1 def +/Landscape false def +/Level1 false def +/Level3 false def +/Rounded false def +/ClipToBoundingBox false def +/SuppressPDFMark false def +/TransparentPatterns false def +/gnulinewidth 5.000 def +/userlinewidth gnulinewidth def +/Gamma 1.0 def +/BackgroundColor {-1.000 -1.000 -1.000} def +% +/vshift -46 def +/dl1 { + 10.0 Dashlength userlinewidth gnulinewidth div mul mul mul + Rounded { currentlinewidth 0.75 mul sub dup 0 le { pop 0.01 } if } if +} def +/dl2 { + 10.0 Dashlength userlinewidth gnulinewidth div mul mul mul + Rounded { currentlinewidth 0.75 mul add } if +} def +/hpt_ 31.5 def +/vpt_ 31.5 def +/hpt hpt_ def +/vpt vpt_ def +/doclip { + ClipToBoundingBox { + newpath 50 50 moveto 410 50 lineto 410 302 lineto 50 302 lineto closepath + clip + } if +} def +% +% Gnuplot Prolog Version 5.1 (Oct 2015) +% +%/SuppressPDFMark true def +% +/M {moveto} bind def +/L {lineto} bind def +/R {rmoveto} bind def +/V {rlineto} bind def +/N {newpath moveto} bind def +/Z {closepath} bind def +/C {setrgbcolor} bind def +/f {rlineto fill} bind def +/g {setgray} bind def +/Gshow {show} def % May be redefined later in the file to support UTF-8 +/vpt2 vpt 2 mul def +/hpt2 hpt 2 mul def +/Lshow {currentpoint stroke M 0 vshift R + Blacktext {gsave 0 setgray textshow grestore} {textshow} ifelse} def +/Rshow {currentpoint stroke M dup stringwidth pop neg vshift R + Blacktext {gsave 0 setgray textshow grestore} {textshow} ifelse} def +/Cshow {currentpoint stroke M dup stringwidth pop -2 div vshift R + Blacktext {gsave 0 setgray textshow grestore} {textshow} ifelse} def +/UP {dup vpt_ mul /vpt exch def hpt_ mul /hpt exch def + /hpt2 hpt 2 mul def /vpt2 vpt 2 mul def} def +/DL {Color {setrgbcolor Solid {pop []} if 0 setdash} + {pop pop pop 0 setgray Solid {pop []} if 0 setdash} ifelse} def +/BL {stroke userlinewidth 2 mul setlinewidth + Rounded {1 setlinejoin 1 setlinecap} if} def +/AL {stroke userlinewidth 2 div setlinewidth + Rounded {1 setlinejoin 1 setlinecap} if} def +/UL {dup gnulinewidth mul /userlinewidth exch def + dup 1 lt {pop 1} if 10 mul /udl exch def} def +/PL {stroke userlinewidth setlinewidth + Rounded {1 setlinejoin 1 setlinecap} if} def +3.8 setmiterlimit +% Classic Line colors (version 5.0) +/LCw {1 1 1} def +/LCb {0 0 0} def +/LCa {0 0 0} def +/LC0 {1 0 0} def +/LC1 {0 1 0} def +/LC2 {0 0 1} def +/LC3 {1 0 1} def +/LC4 {0 1 1} def +/LC5 {1 1 0} def +/LC6 {0 0 0} def +/LC7 {1 0.3 0} def +/LC8 {0.5 0.5 0.5} def +% Default dash patterns (version 5.0) +/LTB {BL [] LCb DL} def +/LTw {PL [] 1 setgray} def +/LTb {PL [] LCb DL} def +/LTa {AL [1 udl mul 2 udl mul] 0 setdash LCa setrgbcolor} def +/LT0 {PL [] LC0 DL} def +/LT1 {PL [2 dl1 3 dl2] LC1 DL} def +/LT2 {PL [1 dl1 1.5 dl2] LC2 DL} def +/LT3 {PL [6 dl1 2 dl2 1 dl1 2 dl2] LC3 DL} def +/LT4 {PL [1 dl1 2 dl2 6 dl1 2 dl2 1 dl1 2 dl2] LC4 DL} def +/LT5 {PL [4 dl1 2 dl2] LC5 DL} def +/LT6 {PL [1.5 dl1 1.5 dl2 1.5 dl1 1.5 dl2 1.5 dl1 6 dl2] LC6 DL} def +/LT7 {PL [3 dl1 3 dl2 1 dl1 3 dl2] LC7 DL} def +/LT8 {PL [2 dl1 2 dl2 2 dl1 6 dl2] LC8 DL} def +/SL {[] 0 setdash} def +/Pnt {stroke [] 0 setdash gsave 1 setlinecap M 0 0 V stroke grestore} def +/Dia {stroke [] 0 setdash 2 copy vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V closepath stroke + Pnt} def +/Pls {stroke [] 0 setdash vpt sub M 0 vpt2 V + currentpoint stroke M + hpt neg vpt neg R hpt2 0 V stroke + } def +/Box {stroke [] 0 setdash 2 copy exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V closepath stroke + Pnt} def +/Crs {stroke [] 0 setdash exch hpt sub exch vpt add M + hpt2 vpt2 neg V currentpoint stroke M + hpt2 neg 0 R hpt2 vpt2 V stroke} def +/TriU {stroke [] 0 setdash 2 copy vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V closepath stroke + Pnt} def +/Star {2 copy Pls Crs} def +/BoxF {stroke [] 0 setdash exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V closepath fill} def +/TriUF {stroke [] 0 setdash vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V closepath fill} def +/TriD {stroke [] 0 setdash 2 copy vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V closepath stroke + Pnt} def +/TriDF {stroke [] 0 setdash vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V closepath fill} def +/DiaF {stroke [] 0 setdash vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V closepath fill} def +/Pent {stroke [] 0 setdash 2 copy gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + closepath stroke grestore Pnt} def +/PentF {stroke [] 0 setdash gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + closepath fill grestore} def +/Circle {stroke [] 0 setdash 2 copy + hpt 0 360 arc stroke Pnt} def +/CircleF {stroke [] 0 setdash hpt 0 360 arc fill} def +/C0 {BL [] 0 setdash 2 copy moveto vpt 90 450 arc} bind def +/C1 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 90 arc closepath fill + vpt 0 360 arc closepath} bind def +/C2 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 90 180 arc closepath fill + vpt 0 360 arc closepath} bind def +/C3 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 180 arc closepath fill + vpt 0 360 arc closepath} bind def +/C4 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 180 270 arc closepath fill + vpt 0 360 arc closepath} bind def +/C5 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 90 arc + 2 copy moveto + 2 copy vpt 180 270 arc closepath fill + vpt 0 360 arc} bind def +/C6 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 90 270 arc closepath fill + vpt 0 360 arc closepath} bind def +/C7 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 270 arc closepath fill + vpt 0 360 arc closepath} bind def +/C8 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 270 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/C9 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 270 450 arc closepath fill + vpt 0 360 arc closepath} bind def +/C10 {BL [] 0 setdash 2 copy 2 copy moveto vpt 270 360 arc closepath fill + 2 copy moveto + 2 copy vpt 90 180 arc closepath fill + vpt 0 360 arc closepath} bind def +/C11 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 180 arc closepath fill + 2 copy moveto + 2 copy vpt 270 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/C12 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 180 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/C13 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 90 arc closepath fill + 2 copy moveto + 2 copy vpt 180 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/C14 {BL [] 0 setdash 2 copy moveto + 2 copy vpt 90 360 arc closepath fill + vpt 0 360 arc} bind def +/C15 {BL [] 0 setdash 2 copy vpt 0 360 arc closepath fill + vpt 0 360 arc closepath} bind def +/Rec {newpath 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto + neg 0 rlineto closepath} bind def +/Square {dup Rec} bind def +/Bsquare {vpt sub exch vpt sub exch vpt2 Square} bind def +/S0 {BL [] 0 setdash 2 copy moveto 0 vpt rlineto BL Bsquare} bind def +/S1 {BL [] 0 setdash 2 copy vpt Square fill Bsquare} bind def +/S2 {BL [] 0 setdash 2 copy exch vpt sub exch vpt Square fill Bsquare} bind def +/S3 {BL [] 0 setdash 2 copy exch vpt sub exch vpt2 vpt Rec fill Bsquare} bind def +/S4 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt Square fill Bsquare} bind def +/S5 {BL [] 0 setdash 2 copy 2 copy vpt Square fill + exch vpt sub exch vpt sub vpt Square fill Bsquare} bind def +/S6 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill Bsquare} bind def +/S7 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill + 2 copy vpt Square fill Bsquare} bind def +/S8 {BL [] 0 setdash 2 copy vpt sub vpt Square fill Bsquare} bind def +/S9 {BL [] 0 setdash 2 copy vpt sub vpt vpt2 Rec fill Bsquare} bind def +/S10 {BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt Square fill + Bsquare} bind def +/S11 {BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt2 vpt Rec fill + Bsquare} bind def +/S12 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill Bsquare} bind def +/S13 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill + 2 copy vpt Square fill Bsquare} bind def +/S14 {BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill + 2 copy exch vpt sub exch vpt Square fill Bsquare} bind def +/S15 {BL [] 0 setdash 2 copy Bsquare fill Bsquare} bind def +/D0 {gsave translate 45 rotate 0 0 S0 stroke grestore} bind def +/D1 {gsave translate 45 rotate 0 0 S1 stroke grestore} bind def +/D2 {gsave translate 45 rotate 0 0 S2 stroke grestore} bind def +/D3 {gsave translate 45 rotate 0 0 S3 stroke grestore} bind def +/D4 {gsave translate 45 rotate 0 0 S4 stroke grestore} bind def +/D5 {gsave translate 45 rotate 0 0 S5 stroke grestore} bind def +/D6 {gsave translate 45 rotate 0 0 S6 stroke grestore} bind def +/D7 {gsave translate 45 rotate 0 0 S7 stroke grestore} bind def +/D8 {gsave translate 45 rotate 0 0 S8 stroke grestore} bind def +/D9 {gsave translate 45 rotate 0 0 S9 stroke grestore} bind def +/D10 {gsave translate 45 rotate 0 0 S10 stroke grestore} bind def +/D11 {gsave translate 45 rotate 0 0 S11 stroke grestore} bind def +/D12 {gsave translate 45 rotate 0 0 S12 stroke grestore} bind def +/D13 {gsave translate 45 rotate 0 0 S13 stroke grestore} bind def +/D14 {gsave translate 45 rotate 0 0 S14 stroke grestore} bind def +/D15 {gsave translate 45 rotate 0 0 S15 stroke grestore} bind def +/DiaE {stroke [] 0 setdash vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V closepath stroke} def +/BoxE {stroke [] 0 setdash exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V closepath stroke} def +/TriUE {stroke [] 0 setdash vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V closepath stroke} def +/TriDE {stroke [] 0 setdash vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V closepath stroke} def +/PentE {stroke [] 0 setdash gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + closepath stroke grestore} def +/CircE {stroke [] 0 setdash + hpt 0 360 arc stroke} def +/Opaque {gsave closepath 1 setgray fill grestore 0 setgray closepath} def +/DiaW {stroke [] 0 setdash vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V Opaque stroke} def +/BoxW {stroke [] 0 setdash exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V Opaque stroke} def +/TriUW {stroke [] 0 setdash vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V Opaque stroke} def +/TriDW {stroke [] 0 setdash vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V Opaque stroke} def +/PentW {stroke [] 0 setdash gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + Opaque stroke grestore} def +/CircW {stroke [] 0 setdash + hpt 0 360 arc Opaque stroke} def +/BoxFill {gsave Rec 1 setgray fill grestore} def +/Density { + /Fillden exch def + currentrgbcolor + /ColB exch def /ColG exch def /ColR exch def + /ColR ColR Fillden mul Fillden sub 1 add def + /ColG ColG Fillden mul Fillden sub 1 add def + /ColB ColB Fillden mul Fillden sub 1 add def + ColR ColG ColB setrgbcolor} def +/BoxColFill {gsave Rec PolyFill} def +/PolyFill {gsave Density fill grestore grestore} def +/h {rlineto rlineto rlineto gsave closepath fill grestore} bind def +% +% PostScript Level 1 Pattern Fill routine for rectangles +% Usage: x y w h s a XX PatternFill +% x,y = lower left corner of box to be filled +% w,h = width and height of box +% a = angle in degrees between lines and x-axis +% XX = 0/1 for no/yes cross-hatch +% +/PatternFill {gsave /PFa [ 9 2 roll ] def + PFa 0 get PFa 2 get 2 div add PFa 1 get PFa 3 get 2 div add translate + PFa 2 get -2 div PFa 3 get -2 div PFa 2 get PFa 3 get Rec + TransparentPatterns {} {gsave 1 setgray fill grestore} ifelse + clip + currentlinewidth 0.5 mul setlinewidth + /PFs PFa 2 get dup mul PFa 3 get dup mul add sqrt def + 0 0 M PFa 5 get rotate PFs -2 div dup translate + 0 1 PFs PFa 4 get div 1 add floor cvi + {PFa 4 get mul 0 M 0 PFs V} for + 0 PFa 6 get ne { + 0 1 PFs PFa 4 get div 1 add floor cvi + {PFa 4 get mul 0 2 1 roll M PFs 0 V} for + } if + stroke grestore} def +% +/languagelevel where + {pop languagelevel} {1} ifelse +dup 2 lt + {/InterpretLevel1 true def + /InterpretLevel3 false def} + {/InterpretLevel1 Level1 def + 2 gt + {/InterpretLevel3 Level3 def} + {/InterpretLevel3 false def} + ifelse } + ifelse +% +% PostScript level 2 pattern fill definitions +% +/Level2PatternFill { +/Tile8x8 {/PaintType 2 /PatternType 1 /TilingType 1 /BBox [0 0 8 8] /XStep 8 /YStep 8} + bind def +/KeepColor {currentrgbcolor [/Pattern /DeviceRGB] setcolorspace} bind def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 0 0 M 8 8 L 0 8 M 8 0 L stroke} +>> matrix makepattern +/Pat1 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 0 0 M 8 8 L 0 8 M 8 0 L stroke + 0 4 M 4 8 L 8 4 L 4 0 L 0 4 L stroke} +>> matrix makepattern +/Pat2 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 0 0 M 0 8 L + 8 8 L 8 0 L 0 0 L fill} +>> matrix makepattern +/Pat3 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop -4 8 M 8 -4 L + 0 12 M 12 0 L stroke} +>> matrix makepattern +/Pat4 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop -4 0 M 8 12 L + 0 -4 M 12 8 L stroke} +>> matrix makepattern +/Pat5 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop -2 8 M 4 -4 L + 0 12 M 8 -4 L 4 12 M 10 0 L stroke} +>> matrix makepattern +/Pat6 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop -2 0 M 4 12 L + 0 -4 M 8 12 L 4 -4 M 10 8 L stroke} +>> matrix makepattern +/Pat7 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 8 -2 M -4 4 L + 12 0 M -4 8 L 12 4 M 0 10 L stroke} +>> matrix makepattern +/Pat8 exch def +<< Tile8x8 + /PaintProc {0.5 setlinewidth pop 0 -2 M 12 4 L + -4 0 M 12 8 L -4 4 M 8 10 L stroke} +>> matrix makepattern +/Pat9 exch def +/Pattern1 {PatternBgnd KeepColor Pat1 setpattern} bind def +/Pattern2 {PatternBgnd KeepColor Pat2 setpattern} bind def +/Pattern3 {PatternBgnd KeepColor Pat3 setpattern} bind def +/Pattern4 {PatternBgnd KeepColor Landscape {Pat5} {Pat4} ifelse setpattern} bind def +/Pattern5 {PatternBgnd KeepColor Landscape {Pat4} {Pat5} ifelse setpattern} bind def +/Pattern6 {PatternBgnd KeepColor Landscape {Pat9} {Pat6} ifelse setpattern} bind def +/Pattern7 {PatternBgnd KeepColor Landscape {Pat8} {Pat7} ifelse setpattern} bind def +} def +% +% +%End of PostScript Level 2 code +% +/PatternBgnd { + TransparentPatterns {} {gsave 1 setgray fill grestore} ifelse +} def +% +% Substitute for Level 2 pattern fill codes with +% grayscale if Level 2 support is not selected. +% +/Level1PatternFill { +/Pattern1 {0.250 Density} bind def +/Pattern2 {0.500 Density} bind def +/Pattern3 {0.750 Density} bind def +/Pattern4 {0.125 Density} bind def +/Pattern5 {0.375 Density} bind def +/Pattern6 {0.625 Density} bind def +/Pattern7 {0.875 Density} bind def +} def +% +% Now test for support of Level 2 code +% +Level1 {Level1PatternFill} {Level2PatternFill} ifelse +% +/Symbol-Oblique /Symbol findfont [1 0 .167 1 0 0] makefont +dup length dict begin {1 index /FID eq {pop pop} {def} ifelse} forall +currentdict end definefont pop +% +/MFshow { + { dup 5 get 3 ge + { 5 get 3 eq {gsave} {grestore} ifelse } + {dup dup 0 get findfont exch 1 get scalefont setfont + [ currentpoint ] exch dup 2 get 0 exch R dup 5 get 2 ne {dup dup 6 + get exch 4 get {textshow} {stringwidth pop 0 R} ifelse }if dup 5 get 0 eq + {dup 3 get {2 get neg 0 exch R pop} {pop aload pop M} ifelse} {dup 5 + get 1 eq {dup 2 get exch dup 3 get exch 6 get stringwidth pop -2 div + dup 0 R} {dup 6 get stringwidth pop -2 div 0 R 6 get + textshow 2 index {aload pop M neg 3 -1 roll neg R pop pop} {pop pop pop + pop aload pop M} ifelse }ifelse }ifelse } + ifelse } + forall} def +/Gswidth {dup type /stringtype eq {stringwidth} {pop (n) stringwidth} ifelse} def +/MFwidth {0 exch { dup 5 get 3 ge { 5 get 3 eq { 0 } { pop } ifelse } + {dup 3 get{dup dup 0 get findfont exch 1 get scalefont setfont + 6 get Gswidth pop add} {pop} ifelse} ifelse} forall} def +/MLshow { currentpoint stroke M + 0 exch R + Blacktext {gsave 0 setgray MFshow grestore} {MFshow} ifelse } bind def +/MRshow { currentpoint stroke M + exch dup MFwidth neg 3 -1 roll R + Blacktext {gsave 0 setgray MFshow grestore} {MFshow} ifelse } bind def +/MCshow { currentpoint stroke M + exch dup MFwidth -2 div 3 -1 roll R + Blacktext {gsave 0 setgray MFshow grestore} {MFshow} ifelse } bind def +/XYsave { [( ) 1 2 true false 3 ()] } bind def +/XYrestore { [( ) 1 2 true false 4 ()] } bind def +Level1 SuppressPDFMark or +{} { +/SDict 10 dict def +systemdict /pdfmark known not { + userdict /pdfmark systemdict /cleartomark get put +} if +SDict begin [ + /Title (spec/tmp/sin_wave_plot.eps) + /Subject (gnuplot plot) + /Creator (gnuplot 5.0 patchlevel 5) +% /Producer (gnuplot) +% /Keywords () + /CreationDate (Fri Nov 22 22:30:52 2019) + /DOCINFO pdfmark +end +} ifelse +% +% Support for boxed text - Ethan A Merritt May 2005 +% +/InitTextBox { userdict /TBy2 3 -1 roll put userdict /TBx2 3 -1 roll put + userdict /TBy1 3 -1 roll put userdict /TBx1 3 -1 roll put + /Boxing true def } def +/ExtendTextBox { Boxing + { gsave dup false charpath pathbbox + dup TBy2 gt {userdict /TBy2 3 -1 roll put} {pop} ifelse + dup TBx2 gt {userdict /TBx2 3 -1 roll put} {pop} ifelse + dup TBy1 lt {userdict /TBy1 3 -1 roll put} {pop} ifelse + dup TBx1 lt {userdict /TBx1 3 -1 roll put} {pop} ifelse + grestore } if } def +/PopTextBox { newpath TBx1 TBxmargin sub TBy1 TBymargin sub M + TBx1 TBxmargin sub TBy2 TBymargin add L + TBx2 TBxmargin add TBy2 TBymargin add L + TBx2 TBxmargin add TBy1 TBymargin sub L closepath } def +/DrawTextBox { PopTextBox stroke /Boxing false def} def +/FillTextBox { gsave PopTextBox 1 1 1 setrgbcolor fill grestore /Boxing false def} def +0 0 0 0 InitTextBox +/TBxmargin 20 def +/TBymargin 20 def +/Boxing false def +/textshow { ExtendTextBox Gshow } def +% +% redundant definitions for compatibility with prologue.ps older than 5.0.2 +/LTB {BL [] LCb DL} def +/LTb {PL [] LCb DL} def +end +%%EndProlog +%%Page: 1 1 +gnudict begin +gsave +doclip +50 50 translate +0.050 0.050 scale +0 setgray +newpath +(Helvetica) findfont 140 scalefont setfont +BackgroundColor 0 lt 3 1 roll 0 lt exch 0 lt or or not {BackgroundColor C 1.000 0 0 7200.00 5040.00 BoxColFill} if +/Helvetica findfont 140 scalefont setfont +/vshift -46 def +1.000 UL +LTb +LCb setrgbcolor +686 448 M +63 0 V +6198 0 R +-63 0 V +stroke +602 448 M +[ [(Helvetica) 140.0 0.0 true true 0 (-1)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 865 M +63 0 V +6198 0 R +-63 0 V +stroke +602 865 M +[ [(Helvetica) 140.0 0.0 true true 0 (-0.8)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 1282 M +63 0 V +6198 0 R +-63 0 V +stroke +602 1282 M +[ [(Helvetica) 140.0 0.0 true true 0 (-0.6)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 1699 M +63 0 V +6198 0 R +-63 0 V +stroke +602 1699 M +[ [(Helvetica) 140.0 0.0 true true 0 (-0.4)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 2116 M +63 0 V +6198 0 R +-63 0 V +stroke +602 2116 M +[ [(Helvetica) 140.0 0.0 true true 0 (-0.2)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 2534 M +63 0 V +6198 0 R +-63 0 V +stroke +602 2534 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 0)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 2951 M +63 0 V +6198 0 R +-63 0 V +stroke +602 2951 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 0.2)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 3368 M +63 0 V +6198 0 R +-63 0 V +stroke +602 3368 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 0.4)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 3785 M +63 0 V +6198 0 R +-63 0 V +stroke +602 3785 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 0.6)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 4202 M +63 0 V +6198 0 R +-63 0 V +stroke +602 4202 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 0.8)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 4619 M +63 0 V +6198 0 R +-63 0 V +stroke +602 4619 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 1)] +] -46.7 MRshow +1.000 UL +LTb +LCb setrgbcolor +686 448 M +0 63 V +0 4108 R +0 -63 V +stroke +686 308 M +[ [(Helvetica) 140.0 0.0 true true 0 (-10)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +2251 448 M +0 63 V +0 4108 R +0 -63 V +stroke +2251 308 M +[ [(Helvetica) 140.0 0.0 true true 0 (-5)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +3817 448 M +0 63 V +0 4108 R +0 -63 V +stroke +3817 308 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 0)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +5382 448 M +0 63 V +0 4108 R +0 -63 V +stroke +5382 308 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 5)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +6947 448 M +0 63 V +0 4108 R +0 -63 V +stroke +6947 308 M +[ [(Helvetica) 140.0 0.0 true true 0 ( 10)] +] -46.7 MCshow +1.000 UL +LTb +LCb setrgbcolor +1.000 UL +LTB +LCb setrgbcolor +686 4619 N +686 448 L +6261 0 V +0 4171 V +-6261 0 V +Z stroke +1.000 UP +1.000 UL +LTb +LCb setrgbcolor +LCb setrgbcolor +112 2533 M +currentpoint gsave translate -270 rotate 0 0 moveto +[ [(Helvetica) 140.0 0.0 true true 0 (x)] +] -46.7 MCshow +grestore +LTb +LCb setrgbcolor +3816 98 M +[ [(Helvetica) 140.0 0.0 true true 0 (sin\(x\))] +] -46.7 MCshow +LTb +LCb setrgbcolor +3816 4829 M +[ [(Helvetica) 140.0 0.0 true true 0 (Sin Wave Example)] +] -46.7 MCshow +% Begin plot #1 +4.000 UL +LTb +LCb setrgbcolor +/Helvetica findfont 140 scalefont setfont +LCb setrgbcolor +6296 4486 M +(sin\(x\)) Rshow +4.000 UL +LTb +LCb setrgbcolor +6380 4486 M +399 0 V +686 3668 M +63 -374 V +63 -405 V +64 -420 V +63 -417 V +63 -397 V +63 -362 V +64 -311 V +63 -248 V +63 -175 V +63 -95 V +64 -10 V +63 74 V +63 156 V +63 231 V +64 297 V +63 350 V +63 390 V +63 414 V +64 420 V +63 411 V +63 383 V +63 341 V +64 284 V +63 216 V +63 140 V +63 57 V +64 -28 V +63 -111 V +63 -191 V +63 -262 V +64 -322 V +63 -370 V +63 -403 V +63 -419 V +63 -418 V +64 -400 V +63 -366 V +63 -317 V +63 -255 V +64 -183 V +63 -103 V +63 -19 V +63 66 V +64 147 V +63 224 V +63 291 V +63 345 V +64 387 V +63 412 V +63 421 V +63 412 V +64 387 V +63 345 V +63 291 V +63 224 V +64 147 V +63 66 V +63 -19 V +63 -103 V +64 -183 V +63 -255 V +63 -317 V +63 -366 V +64 -400 V +63 -418 V +63 -419 V +63 -403 V +63 -370 V +64 -322 V +63 -262 V +63 -191 V +63 -111 V +64 -28 V +63 57 V +63 140 V +63 216 V +64 284 V +63 341 V +63 383 V +63 411 V +64 420 V +63 414 V +63 390 V +63 350 V +64 297 V +63 231 V +63 156 V +63 74 V +64 -10 V +63 -95 V +63 -175 V +63 -248 V +64 -311 V +63 -362 V +63 -397 V +63 -417 V +64 -420 V +63 -405 V +63 -374 V +% End plot #1 +stroke +2.000 UL +LTb +LCb setrgbcolor +1.000 UL +LTB +LCb setrgbcolor +686 4619 N +686 448 L +6261 0 V +0 4171 V +-6261 0 V +Z stroke +1.000 UP +1.000 UL +LTb +LCb setrgbcolor +stroke +grestore +end +showpage +%%Trailer +%%DocumentFonts: Helvetica diff --git a/spec/integration/sinwave_spec.rb b/spec/integration/sinwave_spec.rb new file mode 100644 index 0000000..821502c --- /dev/null +++ b/spec/integration/sinwave_spec.rb @@ -0,0 +1,46 @@ +describe "Sin Wave Plot Example" do + let(:file_path) { 'spec/tmp/sin_wave_plot.eps' } + let(:fixture_path) { 'spec/fixtures/plots/sin_wave_plot.eps' } + + let(:file_content) do + File.read(file_path).gsub(/CreationDate.*/, "") + end + + let(:fixture_content) do + File.read(fixture_path).gsub(/CreationDate.*/, "") + end + + before do + path = file_path + + Gnuplot.open do |gp| + Gnuplot::Plot.new( gp ) do |plot| + + plot.xrange "[-10:10]" + plot.title "Sin Wave Example" + plot.ylabel "x" + plot.xlabel "sin(x)" + + plot.term "postscript eps" + plot.output path + + plot.data << Gnuplot::DataSet.new( "sin(x)" ) do |ds| + ds.with = "lines" + ds.linewidth = 4 + end + + end + + end + + end + + after do + File.delete(file_path) + end + + it "plots expected file" do + expect(file_content).to eq(fixture_content) + end +end + From 67245c701d6100da60d54a1bf9f48bd682ccc049 Mon Sep 17 00:00:00 2001 From: darthjee Date: Sun, 24 Nov 2019 10:21:41 +0100 Subject: [PATCH 38/55] Add initialization spec --- spec/lib/ruby_gnuplot/plot_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/lib/ruby_gnuplot/plot_spec.rb b/spec/lib/ruby_gnuplot/plot_spec.rb index c45ce23..b831ef5 100644 --- a/spec/lib/ruby_gnuplot/plot_spec.rb +++ b/spec/lib/ruby_gnuplot/plot_spec.rb @@ -47,5 +47,21 @@ expect(plot.to_gplot).to eq(expected_string) end end + + context "when setting from inside initialization" do + subject(:plot) do + described_class.new do |p| + p.title "Array Plot Example" + p.ylabel "x" + p.xlabel "x^2" + p.term "postscript eps" + p.output "file.eps" + end + end + + it "wraps strings with quotes when needed" do + expect(plot.to_gplot).to eq(expected_string) + end + end end end From 6cd22ae7c4aa28410fc93004f1906af6360b7143 Mon Sep 17 00:00:00 2001 From: darthjee Date: Sun, 24 Nov 2019 10:32:48 +0100 Subject: [PATCH 39/55] Add quotting sets spec --- spec/lib/ruby_gnuplot/plot_spec.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec/lib/ruby_gnuplot/plot_spec.rb b/spec/lib/ruby_gnuplot/plot_spec.rb index b831ef5..a69a1ee 100644 --- a/spec/lib/ruby_gnuplot/plot_spec.rb +++ b/spec/lib/ruby_gnuplot/plot_spec.rb @@ -1,3 +1,15 @@ +shared_examples 'quotes value when setting in a plot for' do |field| + describe "##{field}" do + before do + plot.public_send(field, 'text') + end + + it 'quotes value when setting it' do + expect(plot.to_gplot).to eq("set #{field} \"text\"\n") + end + end +end + describe Gnuplot::Plot do subject(:plot) { described_class.new } @@ -64,4 +76,14 @@ end end end + + it_behaves_like 'quotes value when setting in a plot for', :title + it_behaves_like 'quotes value when setting in a plot for', :output + it_behaves_like 'quotes value when setting in a plot for', :xlabel + it_behaves_like 'quotes value when setting in a plot for', :x2label + it_behaves_like 'quotes value when setting in a plot for', :ylabel + it_behaves_like 'quotes value when setting in a plot for', :y2label + it_behaves_like 'quotes value when setting in a plot for', :clabel + it_behaves_like 'quotes value when setting in a plot for', :cblabel + it_behaves_like 'quotes value when setting in a plot for', :zlabel end From 9ee1f5bb79312c0725847a7b518d9e92322a6cce Mon Sep 17 00:00:00 2001 From: darthjee Date: Sun, 24 Nov 2019 10:38:58 +0100 Subject: [PATCH 40/55] Placeholder for style spec --- spec/lib/ruby_gnuplot/style_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 spec/lib/ruby_gnuplot/style_spec.rb diff --git a/spec/lib/ruby_gnuplot/style_spec.rb b/spec/lib/ruby_gnuplot/style_spec.rb new file mode 100644 index 0000000..8383fb8 --- /dev/null +++ b/spec/lib/ruby_gnuplot/style_spec.rb @@ -0,0 +1,5 @@ +describe Gnuplot::Plot do + subject(:style) { described_class.new } + + xit "Adds tests here" +end From 4e023d68f481830ed93dc3652eb6f2c30b19d00a Mon Sep 17 00:00:00 2001 From: darthjee Date: Sun, 24 Nov 2019 13:03:03 +0100 Subject: [PATCH 41/55] Add Plot#[] spec --- spec/lib/ruby_gnuplot/plot_spec.rb | 55 ++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/spec/lib/ruby_gnuplot/plot_spec.rb b/spec/lib/ruby_gnuplot/plot_spec.rb index a69a1ee..e0ca332 100644 --- a/spec/lib/ruby_gnuplot/plot_spec.rb +++ b/spec/lib/ruby_gnuplot/plot_spec.rb @@ -86,4 +86,59 @@ it_behaves_like 'quotes value when setting in a plot for', :clabel it_behaves_like 'quotes value when setting in a plot for', :cblabel it_behaves_like 'quotes value when setting in a plot for', :zlabel + + describe '[]' do + context 'when value was never set' do + it { expect(plot['key']).to be_nil } + end + + context 'when value was only unset' do + before { plot.unset 'title' } + + it { expect(plot['title']).to be_nil } + end + + context 'when value was set only once' do + before { plot.title "My Title" } + + it "returns the value to be used (quoted when needed)" do + expect(plot['title']).to eq('"My Title"') + end + end + + context 'when value was set twice' do + before do + plot.title "My Title" + plot.title "My New Title" + end + + # TODO: check specification + xit "returns the last value set" do + expect(plot['title']).to eq('"My New Title"') + end + end + + context 'when value was set then unset' do + before do + plot.title "My Title" + plot.unset "title" + end + + # TODO: check specification + xit { expect(plot['title']).to be_nil } + end + + context 'when value was set, unset and set again' do + before do + plot.title "My Title" + plot.unset "title" + plot.title "My New Title" + end + + # TODO: check specification + xit "returns the last value set" do + expect(plot['title']).to eq('"My New Title"') + end + end + end end From ff92d733b8aed7559d89b4e3dab0face6d8a59c1 Mon Sep 17 00:00:00 2001 From: darthjee Date: Sun, 24 Nov 2019 13:16:34 +0100 Subject: [PATCH 42/55] Add spec over Plot#unset --- spec/lib/ruby_gnuplot/plot_spec.rb | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/spec/lib/ruby_gnuplot/plot_spec.rb b/spec/lib/ruby_gnuplot/plot_spec.rb index e0ca332..1753526 100644 --- a/spec/lib/ruby_gnuplot/plot_spec.rb +++ b/spec/lib/ruby_gnuplot/plot_spec.rb @@ -87,7 +87,33 @@ it_behaves_like 'quotes value when setting in a plot for', :cblabel it_behaves_like 'quotes value when setting in a plot for', :zlabel - describe '[]' do + describe '#unset' do + let(:expected_string) do + [ + 'set title "My Title"', + 'unset title', + '' + ].join("\n") + end + + before do + plot.title 'My Title' + end + + # TODO: check specification + xit 'changes value in current settings' do + expect { plot.unset 'title' } + .to change { plot['title'] } + .from('My title').to(nil) + end + + it 'unsets key on output' do + plot.unset 'title' + expect(plot.to_gplot).to eq(expected_string) + end + end + + describe '#[]' do context 'when value was never set' do it { expect(plot['key']).to be_nil } end From 1134bb52aeb97da56d1e9983ec39fc26db3344ce Mon Sep 17 00:00:00 2001 From: darthjee Date: Mon, 25 Nov 2019 09:23:09 +0100 Subject: [PATCH 43/55] Checks changes in settings --- spec/lib/ruby_gnuplot/plot_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/lib/ruby_gnuplot/plot_spec.rb b/spec/lib/ruby_gnuplot/plot_spec.rb index 1753526..5913d63 100644 --- a/spec/lib/ruby_gnuplot/plot_spec.rb +++ b/spec/lib/ruby_gnuplot/plot_spec.rb @@ -7,6 +7,16 @@ it 'quotes value when setting it' do expect(plot.to_gplot).to eq("set #{field} \"text\"\n") end + + it 'enquees into settings' do + expect { plot.public_send(field, 'new text') } + .to change(plot, :settings) + .from([[:set, field.to_s, '"text"']]) + .to([ + [:set, field.to_s, '"text"'], + [:set, field.to_s, '"new text"'] + ]) + end end end From 2a802c3bd3dbf4bca32eb4c8b4610f079b6e6132 Mon Sep 17 00:00:00 2001 From: darthjee Date: Mon, 25 Nov 2019 09:27:12 +0100 Subject: [PATCH 44/55] Add method missing spec --- spec/lib/ruby_gnuplot/plot_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/lib/ruby_gnuplot/plot_spec.rb b/spec/lib/ruby_gnuplot/plot_spec.rb index 5913d63..f514695 100644 --- a/spec/lib/ruby_gnuplot/plot_spec.rb +++ b/spec/lib/ruby_gnuplot/plot_spec.rb @@ -177,4 +177,22 @@ end end end + + describe 'method missing' do + it 'delegates to set call' do + expect { plot.fake_field('value') } + .to change(plot, :settings) + .from([]) + .to([[:set, 'fake_field', 'value']]) + end + + context 'when field should be quoted' do + it 'delegates to set call and quote it' do + expect { plot.output('value') } + .to change(plot, :settings) + .from([]) + .to([[:set, 'output', '"value"']]) + end + end + end end From b4424337da0cbd5ed0973ab71516425fe5d4779c Mon Sep 17 00:00:00 2001 From: darthjee Date: Tue, 26 Nov 2019 09:18:01 +0100 Subject: [PATCH 45/55] Add spec over style class --- spec/lib/ruby_gnuplot/style_spec.rb | 65 ++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/spec/lib/ruby_gnuplot/style_spec.rb b/spec/lib/ruby_gnuplot/style_spec.rb index 8383fb8..b80f845 100644 --- a/spec/lib/ruby_gnuplot/style_spec.rb +++ b/spec/lib/ruby_gnuplot/style_spec.rb @@ -1,5 +1,66 @@ -describe Gnuplot::Plot do +describe Gnuplot::Plot::Style do subject(:style) { described_class.new } - xit "Adds tests here" + let(:index) { style.index } + + describe '#to_s' do + context "when nothing has been set" do + it 'creates an empty style' do + expect(style.to_s).to eq("set style line #{index}") + end + end + + context 'when setting the stype' do + before do + style.ls = 1 + style.lw = 2 + style.lc = 3 + style.pt = 4 + style.ps = 5 + style.fs = 6 + end + + it 'creates and indexes the style' do + expect(style.to_s).to eq( + "set style line #{index} ls 1 lw 2 lc 3 pt 4 ps 5 fs 6" + ) + end + end + + context 'when setting the stype on initialize' do + subject(:style) do + described_class.new do |style| + style.ls = 1 + style.lw = 2 + style.lc = 3 + style.pt = 4 + style.ps = 5 + style.fs = 6 + end + end + + it 'creates and indexes the style' do + expect(style.to_s).to eq( + "set style line #{index} ls 1 lw 2 lc 3 pt 4 ps 5 fs 6" + ) + end + end + + context 'when setting using the full method name' do + before do + style.linestyle = 1 + style.linewidth = 2 + style.linecolor = 3 + style.pointtype = 4 + style.pointsize = 5 + style.fill = 6 + end + + it 'creates and indexes the style' do + expect(style.to_s).to eq( + "set style line #{index} ls 1 lw 2 lc 3 pt 4 ps 5 fs 6" + ) + end + end + end end From cf8c5024b4681eaf6d36127a8815de18daab95d3 Mon Sep 17 00:00:00 2001 From: darthjee Date: Tue, 26 Nov 2019 10:17:05 +0100 Subject: [PATCH 46/55] Fix Plot#[] --- lib/gnuplot.rb | 2 +- spec/lib/ruby_gnuplot/plot_spec.rb | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/gnuplot.rb b/lib/gnuplot.rb index 592b3e6..21ca23d 100644 --- a/lib/gnuplot.rb +++ b/lib/gnuplot.rb @@ -140,7 +140,7 @@ def unset ( var ) # gnuplot process. def [] ( var ) - v = @settings.rassoc( var ) + v = @settings.reverse.rassoc( var ) if v.nil? or v.first == :unset nil else diff --git a/spec/lib/ruby_gnuplot/plot_spec.rb b/spec/lib/ruby_gnuplot/plot_spec.rb index f514695..8e86d43 100644 --- a/spec/lib/ruby_gnuplot/plot_spec.rb +++ b/spec/lib/ruby_gnuplot/plot_spec.rb @@ -111,10 +111,10 @@ end # TODO: check specification - xit 'changes value in current settings' do + it 'changes value in current settings' do expect { plot.unset 'title' } .to change { plot['title'] } - .from('My title').to(nil) + .from('"My Title"').to(nil) end it 'unsets key on output' do @@ -149,7 +149,7 @@ end # TODO: check specification - xit "returns the last value set" do + it "returns the last value set" do expect(plot['title']).to eq('"My New Title"') end end @@ -161,7 +161,7 @@ end # TODO: check specification - xit { expect(plot['title']).to be_nil } + it { expect(plot['title']).to be_nil } end context 'when value was set, unset and set again' do @@ -172,7 +172,7 @@ end # TODO: check specification - xit "returns the last value set" do + it "returns the last value set" do expect(plot['title']).to eq('"My New Title"') end end From 5e0055f4ca7fc7ca6bfc70c7bc61956026b03e5f Mon Sep 17 00:00:00 2001 From: darthjee Date: Tue, 26 Nov 2019 10:19:20 +0100 Subject: [PATCH 47/55] Fix Plot#[] --- lib/gnuplot.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gnuplot.rb b/lib/gnuplot.rb index 592b3e6..21ca23d 100644 --- a/lib/gnuplot.rb +++ b/lib/gnuplot.rb @@ -140,7 +140,7 @@ def unset ( var ) # gnuplot process. def [] ( var ) - v = @settings.rassoc( var ) + v = @settings.reverse.rassoc( var ) if v.nil? or v.first == :unset nil else From 8a0702c10861c3ecb5383adec7b69758be7effe4 Mon Sep 17 00:00:00 2001 From: darthjee Date: Tue, 26 Nov 2019 17:15:38 +0100 Subject: [PATCH 48/55] Add rubocop --- .rubocop.yml | 2 + .rubocop_todo.yml | 654 +++++++++++++++++++++++++++++++++++++++++++ ruby_gnuplot.gemspec | 6 +- 3 files changed, 660 insertions(+), 2 deletions(-) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..6cc5ed4 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,2 @@ +require: rubocop-rspec +inherit_from: .rubocop_todo.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..2d1a124 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,654 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2019-11-26 16:16:51 +0000 using RuboCop version 0.73.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: with_first_argument, with_fixed_indentation +Layout/AlignArguments: + Exclude: + - 'lib/gnuplot.rb' + - 'test/test_gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/AlignArray: + Exclude: + - 'test/test_gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLineAfterGuardClause: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLineAfterMagicComment: + Exclude: + - 'ruby_gnuplot.gemspec' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. +Layout/EmptyLineBetweenDefs: + Exclude: + - 'lib/gnuplot.rb' + - 'test/test_gnuplot.rb' + +# Offense count: 13 +# Cop supports --auto-correct. +Layout/EmptyLines: + Exclude: + - 'lib/gnuplot.rb' + - 'spec/lib/ruby_gnuplot/plot_spec.rb' + - 'test/test_gnuplot.rb' + +# Offense count: 21 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, no_empty_lines +Layout/EmptyLinesAroundBlockBody: + Exclude: + - 'examples/multiple_data_sets.rb' + - 'spec/integration/arrtest_spec.rb' + - 'spec/integration/histtest_spec.rb' + - 'spec/integration/multtest_spec.rb' + - 'spec/integration/sinwave_spec.rb' + - 'test/arrtest.rb' + - 'test/multtest.rb' + - 'test/sinwave.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only +Layout/EmptyLinesAroundClassBody: + Exclude: + - 'lib/gnuplot.rb' + - 'test/test_gnuplot.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundMethodBody: + Exclude: + - 'lib/gnuplot.rb' + - 'test/test_gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Layout/EmptyLinesAroundModuleBody: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. +Layout/ExtraSpacing: + Exclude: + - 'test/test_gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: IndentationWidth. +Layout/IndentAssignment: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_brackets +Layout/IndentFirstArrayElement: + EnforcedStyle: consistent + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: normal, indented_internal_methods +Layout/IndentationConsistency: + Exclude: + - 'examples/multiple_data_sets.rb' + - 'lib/gnuplot.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: Width, IgnoredPatterns. +Layout/IndentationWidth: + Exclude: + - 'examples/3d_surface_plot.rb' + - 'lib/gnuplot.rb' + - 'spec/integration/multtest_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/SpaceAfterComma: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 13 +# Cop supports --auto-correct. +Layout/SpaceAfterMethodName: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceAroundEqualsInParameterDefault: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment. +Layout/SpaceAroundOperators: + Exclude: + - 'examples/discrete_points.rb' + - 'examples/multiple_data_sets.rb' + - 'ruby_gnuplot.gemspec' + - 'spec/integration/arrtest_spec.rb' + - 'spec/integration/histtest_spec.rb' + - 'spec/integration/multtest_spec.rb' + - 'test/arrtest.rb' + - 'test/histtest.rb' + - 'test/multtest.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceBeforeBlockBraces: + Exclude: + - 'examples/histogram.rb' + - 'lib/gnuplot.rb' + +# Offense count: 18 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideArrayLiteralBrackets: + Exclude: + - 'lib/gnuplot.rb' + - 'test/test_gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/SpaceInsideArrayPercentLiteral: + Exclude: + - 'examples/histogram.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideBlockBraces: + Exclude: + - 'examples/histogram.rb' + - 'lib/gnuplot.rb' + +# Offense count: 120 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceInsideParens: + Enabled: false + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: IndentationWidth. +Layout/Tab: + Exclude: + - 'examples/3d_surface_plot.rb' + - 'examples/multiple_data_sets.rb' + - 'lib/gnuplot.rb' + - 'test/test_gnuplot.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: final_newline, final_blank_line +Layout/TrailingBlankLines: + Exclude: + - 'examples/histogram.rb' + - 'examples/sin_wave.rb' + - 'spec/integration/multtest_spec.rb' + - 'spec/integration/sinwave_spec.rb' + - 'test/arrtest.rb' + - 'test/histtest.rb' + - 'test/multtest.rb' + - 'test/sinwave.rb' + - 'test/test_gnuplot.rb' + +# Offense count: 27 +# Cop supports --auto-correct. +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Exclude: + - 'examples/discrete_points.rb' + - 'examples/histogram.rb' + - 'examples/multiple_data_sets.rb' + - 'examples/output_image_file.rb' + - 'examples/sin_wave.rb' + +# Offense count: 1 +Lint/AmbiguousOperator: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 2 +Lint/ShadowingOuterLocalVariable: + Exclude: + - 'test/test_gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Exclude: + - 'test/histtest.rb' + +# Offense count: 1 +Lint/UselessAssignment: + Exclude: + - 'test/test_gnuplot.rb' + +# Offense count: 3 +Metrics/AbcSize: + Max: 23 + +# Offense count: 9 +# Configuration parameters: CountComments, ExcludedMethods. +# ExcludedMethods: refine +Metrics/BlockLength: + Max: 143 + +# Offense count: 1 +Metrics/CyclomaticComplexity: + Max: 13 + +# Offense count: 8 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/MethodLength: + Max: 22 + +# Offense count: 1 +Metrics/PerceivedComplexity: + Max: 12 + +# Offense count: 1 +# Configuration parameters: EnforcedStyleForLeadingUnderscores. +# SupportedStylesForLeadingUnderscores: disallowed, required, optional +Naming/MemoizedInstanceVariableName: + Exclude: + - 'Rakefile' + +# Offense count: 4 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: io, id, to, by, on, in, at, ip, db +Naming/UncommunicativeMethodParamName: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 1 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: snake_case, camelCase +Naming/VariableName: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 4 +RSpec/DescribeClass: + Exclude: + - 'spec/integration/arrtest_spec.rb' + - 'spec/integration/histtest_spec.rb' + - 'spec/integration/multtest_spec.rb' + - 'spec/integration/sinwave_spec.rb' + +# Offense count: 1 +# Configuration parameters: Max. +RSpec/ExampleLength: + Exclude: + - 'spec/lib/ruby_gnuplot/plot_spec.rb' + +# Offense count: 1 +# Configuration parameters: CustomTransform, IgnoreMethods. +RSpec/FilePath: + Exclude: + - 'spec/lib/ruby_gnuplot/style_spec.rb' + +# Offense count: 1 +Security/Eval: + Exclude: + - 'Rakefile' + +# Offense count: 16 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: prefer_alias, prefer_alias_method +Style/Alias: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, conditionals +Style/AndOr: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/BlockComments: + Exclude: + - 'spec/spec_helper.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners. +# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces +# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object +# FunctionalMethods: let, let!, subject, watch +# IgnoredMethods: lambda, proc, it +Style/BlockDelimiters: + Exclude: + - 'examples/multiple_data_sets.rb' + - 'lib/gnuplot.rb' + - 'spec/integration/multtest_spec.rb' + - 'test/multtest.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: is_a?, kind_of? +Style/ClassCheck: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Style/ClassMethods: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +Style/ColonMethodCall: + Exclude: + - 'lib/gnuplot.rb' + - 'test/test_gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. +# SupportedStyles: assign_to_condition, assign_inside_condition +Style/ConditionalAssignment: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 7 +Style/Documentation: + Exclude: + - 'spec/**/*' + - 'test/**/*' + - 'lib/gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/Encoding: + Exclude: + - 'ruby_gnuplot.gemspec' + +# Offense count: 9 +# Cop supports --auto-correct. +Style/ExpandPathArguments: + Exclude: + - 'Rakefile' + - 'examples/3d_surface_plot.rb' + - 'examples/discrete_points.rb' + - 'examples/histogram.rb' + - 'examples/multiple_data_sets.rb' + - 'examples/output_image_file.rb' + - 'examples/sin_wave.rb' + - 'ruby_gnuplot.gemspec' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: each, for +Style/For: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 23 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 1 +# Configuration parameters: MinBodyLength. +Style/GuardClause: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +Style/HashSyntax: + EnforcedStyle: hash_rockets + +# Offense count: 3 +# Cop supports --auto-correct. +Style/IfUnlessModifier: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 1 +Style/IfUnlessModifierOfIfUnless: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +Style/MethodCallWithoutArgsParentheses: + Exclude: + - 'test/histtest.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline +Style/MethodDefParentheses: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 1 +Style/MethodMissingSuper: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 1 +Style/MissingRespondToMissing: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/MultilineIfThen: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: + Exclude: + - 'lib/gnuplot.rb' + - 'lib/ruby_gnuplot/version.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: both, prefix, postfix +Style/NegatedIf: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/NestedModifier: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/Not: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 18 +# Cop supports --auto-correct. +# Configuration parameters: Strict. +Style/NumericLiterals: + MinDigits: 7 + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'spec/**/*' + - 'lib/gnuplot.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions. +Style/ParenthesesAroundCondition: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'examples/histogram.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Style/RedundantSelf: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: use_perl_names, use_english_names +Style/SpecialGlobalVars: + Exclude: + - 'ruby_gnuplot.gemspec' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/StderrPuts: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 235 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: MinSize. +# SupportedStyles: percent, brackets +Style/SymbolArray: + EnforcedStyle: brackets + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +# IgnoredMethods: respond_to, define_method +Style/SymbolProc: + Exclude: + - 'examples/discrete_points.rb' + - 'examples/histogram.rb' + - 'examples/multiple_data_sets.rb' + - 'lib/gnuplot.rb' + - 'spec/integration/arrtest_spec.rb' + - 'spec/integration/multtest_spec.rb' + - 'test/arrtest.rb' + - 'test/multtest.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, AllowSafeAssignment. +# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex +Style/TernaryParentheses: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArrayLiteral: + Exclude: + - 'examples/histogram.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: percent + MinSize: 10 + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: forbid_for_all_comparison_operators, forbid_for_equality_operators_only, require_for_all_comparison_operators, require_for_equality_operators_only +Style/YodaCondition: + Exclude: + - 'test/test_gnuplot.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ZeroLengthPredicate: + Exclude: + - 'lib/gnuplot.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 115 diff --git a/ruby_gnuplot.gemspec b/ruby_gnuplot.gemspec index c070c96..97239a1 100644 --- a/ruby_gnuplot.gemspec +++ b/ruby_gnuplot.gemspec @@ -18,6 +18,8 @@ Gem::Specification.new do |s| s.require_paths = ["lib"] s.add_development_dependency 'minitest' - s.add_development_dependency 'rspec', '3.9.0' - s.add_development_dependency 'simplecov', '0.17.0' + s.add_development_dependency 'rspec', '3.9.0' + s.add_development_dependency 'rubocop', '0.73.0' + s.add_development_dependency 'rubocop-rspec', '1.33.0' + s.add_development_dependency 'simplecov', '0.17.0' end From 91fca063b14d82f4c394ce47a24f8247130224b7 Mon Sep 17 00:00:00 2001 From: darthjee Date: Tue, 26 Nov 2019 17:18:35 +0100 Subject: [PATCH 49/55] Apply rubocop fixes --- .rubocop.yml | 7 ++ .rubocop_todo.yml | 66 ++--------- spec/integration/arrtest_spec.rb | 6 +- spec/integration/histtest_spec.rb | 3 +- spec/integration/multtest_spec.rb | 19 ++-- spec/integration/sinwave_spec.rb | 5 - .../lib/ruby_gnuplot/{ => plot}/style_spec.rb | 0 spec/lib/ruby_gnuplot/plot_spec.rb | 13 ++- spec/spec_helper.rb | 104 +++++++++--------- spec/support/models/random_generator.rb | 2 +- 10 files changed, 86 insertions(+), 139 deletions(-) rename spec/lib/ruby_gnuplot/{ => plot}/style_spec.rb (100%) diff --git a/.rubocop.yml b/.rubocop.yml index 6cc5ed4..2b2ba5e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,2 +1,9 @@ require: rubocop-rspec inherit_from: .rubocop_todo.yml + +AllCops: + TargetRubyVersion: 2.5 + +RSpec/DescribeClass: + Exclude: + - 'spec/**/*_spec.rb' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2d1a124..961b79d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2019-11-26 16:16:51 +0000 using RuboCop version 0.73.0. +# on 2019-11-26 16:32:38 +0000 using RuboCop version 0.73.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -41,25 +41,20 @@ Layout/EmptyLineBetweenDefs: - 'lib/gnuplot.rb' - 'test/test_gnuplot.rb' -# Offense count: 13 +# Offense count: 12 # Cop supports --auto-correct. Layout/EmptyLines: Exclude: - 'lib/gnuplot.rb' - - 'spec/lib/ruby_gnuplot/plot_spec.rb' - 'test/test_gnuplot.rb' -# Offense count: 21 +# Offense count: 10 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, no_empty_lines Layout/EmptyLinesAroundBlockBody: Exclude: - 'examples/multiple_data_sets.rb' - - 'spec/integration/arrtest_spec.rb' - - 'spec/integration/histtest_spec.rb' - - 'spec/integration/multtest_spec.rb' - - 'spec/integration/sinwave_spec.rb' - 'test/arrtest.rb' - 'test/multtest.rb' - 'test/sinwave.rb' @@ -102,13 +97,6 @@ Layout/IndentAssignment: Exclude: - 'lib/gnuplot.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_brackets -Layout/IndentFirstArrayElement: - EnforcedStyle: consistent - # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. @@ -118,14 +106,13 @@ Layout/IndentationConsistency: - 'examples/multiple_data_sets.rb' - 'lib/gnuplot.rb' -# Offense count: 6 +# Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: Width, IgnoredPatterns. Layout/IndentationWidth: Exclude: - 'examples/3d_surface_plot.rb' - 'lib/gnuplot.rb' - - 'spec/integration/multtest_spec.rb' # Offense count: 2 # Cop supports --auto-correct. @@ -147,7 +134,7 @@ Layout/SpaceAroundEqualsInParameterDefault: Exclude: - 'lib/gnuplot.rb' -# Offense count: 9 +# Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment. Layout/SpaceAroundOperators: @@ -155,9 +142,6 @@ Layout/SpaceAroundOperators: - 'examples/discrete_points.rb' - 'examples/multiple_data_sets.rb' - 'ruby_gnuplot.gemspec' - - 'spec/integration/arrtest_spec.rb' - - 'spec/integration/histtest_spec.rb' - - 'spec/integration/multtest_spec.rb' - 'test/arrtest.rb' - 'test/histtest.rb' - 'test/multtest.rb' @@ -215,7 +199,7 @@ Layout/Tab: - 'lib/gnuplot.rb' - 'test/test_gnuplot.rb' -# Offense count: 9 +# Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: final_newline, final_blank_line @@ -223,8 +207,6 @@ Layout/TrailingBlankLines: Exclude: - 'examples/histogram.rb' - 'examples/sin_wave.rb' - - 'spec/integration/multtest_spec.rb' - - 'spec/integration/sinwave_spec.rb' - 'test/arrtest.rb' - 'test/histtest.rb' - 'test/multtest.rb' @@ -308,26 +290,6 @@ Naming/VariableName: Exclude: - 'lib/gnuplot.rb' -# Offense count: 4 -RSpec/DescribeClass: - Exclude: - - 'spec/integration/arrtest_spec.rb' - - 'spec/integration/histtest_spec.rb' - - 'spec/integration/multtest_spec.rb' - - 'spec/integration/sinwave_spec.rb' - -# Offense count: 1 -# Configuration parameters: Max. -RSpec/ExampleLength: - Exclude: - - 'spec/lib/ruby_gnuplot/plot_spec.rb' - -# Offense count: 1 -# Configuration parameters: CustomTransform, IgnoreMethods. -RSpec/FilePath: - Exclude: - - 'spec/lib/ruby_gnuplot/style_spec.rb' - # Offense count: 1 Security/Eval: Exclude: @@ -349,13 +311,7 @@ Style/AndOr: Exclude: - 'lib/gnuplot.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Style/BlockComments: - Exclude: - - 'spec/spec_helper.rb' - -# Offense count: 8 +# Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners. # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces @@ -366,7 +322,6 @@ Style/BlockDelimiters: Exclude: - 'examples/multiple_data_sets.rb' - 'lib/gnuplot.rb' - - 'spec/integration/multtest_spec.rb' - 'test/multtest.rb' # Offense count: 2 @@ -535,7 +490,6 @@ Style/NumericLiterals: # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: - - 'spec/**/*' - 'lib/gnuplot.rb' # Offense count: 3 @@ -593,7 +547,7 @@ Style/StringLiterals: Style/SymbolArray: EnforcedStyle: brackets -# Offense count: 9 +# Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: IgnoredMethods. # IgnoredMethods: respond_to, define_method @@ -603,8 +557,6 @@ Style/SymbolProc: - 'examples/histogram.rb' - 'examples/multiple_data_sets.rb' - 'lib/gnuplot.rb' - - 'spec/integration/arrtest_spec.rb' - - 'spec/integration/multtest_spec.rb' - 'test/arrtest.rb' - 'test/multtest.rb' @@ -646,7 +598,7 @@ Style/ZeroLengthPredicate: Exclude: - 'lib/gnuplot.rb' -# Offense count: 7 +# Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https diff --git a/spec/integration/arrtest_spec.rb b/spec/integration/arrtest_spec.rb index a5ae38e..49485f4 100644 --- a/spec/integration/arrtest_spec.rb +++ b/spec/integration/arrtest_spec.rb @@ -15,15 +15,14 @@ Gnuplot.open do |gp| Gnuplot::Plot.new( gp ) do |plot| - plot.title "Array Plot Example" plot.ylabel "x" plot.xlabel "x^2" plot.term "postscript eps" plot.output path - x = (0..50).collect { |v| v.to_f } - y = x.collect { |v| v ** 2 } + x = (0..50).collect(&:to_f) + y = x.collect { |v| v**2 } plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds| ds.with = "linespoints" @@ -31,7 +30,6 @@ end end end - end after do diff --git a/spec/integration/histtest_spec.rb b/spec/integration/histtest_spec.rb index 3cc98fa..7301023 100644 --- a/spec/integration/histtest_spec.rb +++ b/spec/integration/histtest_spec.rb @@ -15,7 +15,7 @@ RandomGenerator.seed(0.17) collection = (0..500).collect do - (RandomGenerator.rand-0.5)**3 + (RandomGenerator.rand - 0.5)**3 end Gnuplot.open do |gp| @@ -37,7 +37,6 @@ plot.output path end end - end after do diff --git a/spec/integration/multtest_spec.rb b/spec/integration/multtest_spec.rb index 31c5923..3da4043 100644 --- a/spec/integration/multtest_spec.rb +++ b/spec/integration/multtest_spec.rb @@ -15,7 +15,6 @@ Gnuplot.open do |gp| Gnuplot::Plot.new( gp ) do |plot| - plot.xrange "[-10:10]" plot.title "Sin Wave Example" plot.ylabel "x" @@ -24,34 +23,30 @@ plot.term "postscript eps" plot.output path - x = (0..50).collect { |v| v.to_f } - y = x.collect { |v| v ** 2 } + x = (0..50).collect(&:to_f) + y = x.collect { |v| v**2 } plot.data = [ - Gnuplot::DataSet.new( "sin(x)" ) { |ds| + Gnuplot::DataSet.new( "sin(x)" ) do |ds| ds.with = "lines" ds.title = "String function" ds.linewidth = 4 - }, + end, - Gnuplot::DataSet.new( [x, y] ) { |ds| + Gnuplot::DataSet.new( [x, y] ) do |ds| ds.with = "linespoints" ds.title = "Array data" - } + end ] - end - end - end after do - File.delete(file_path) + File.delete(file_path) end it "plots expected file" do expect(file_content).to eq(fixture_content) end end - diff --git a/spec/integration/sinwave_spec.rb b/spec/integration/sinwave_spec.rb index 821502c..c27e7f5 100644 --- a/spec/integration/sinwave_spec.rb +++ b/spec/integration/sinwave_spec.rb @@ -15,7 +15,6 @@ Gnuplot.open do |gp| Gnuplot::Plot.new( gp ) do |plot| - plot.xrange "[-10:10]" plot.title "Sin Wave Example" plot.ylabel "x" @@ -28,11 +27,8 @@ ds.with = "lines" ds.linewidth = 4 end - end - end - end after do @@ -43,4 +39,3 @@ expect(file_content).to eq(fixture_content) end end - diff --git a/spec/lib/ruby_gnuplot/style_spec.rb b/spec/lib/ruby_gnuplot/plot/style_spec.rb similarity index 100% rename from spec/lib/ruby_gnuplot/style_spec.rb rename to spec/lib/ruby_gnuplot/plot/style_spec.rb diff --git a/spec/lib/ruby_gnuplot/plot_spec.rb b/spec/lib/ruby_gnuplot/plot_spec.rb index 8e86d43..4acdd21 100644 --- a/spec/lib/ruby_gnuplot/plot_spec.rb +++ b/spec/lib/ruby_gnuplot/plot_spec.rb @@ -4,6 +4,13 @@ plot.public_send(field, 'text') end + let(:expected_settings) do + [ + [:set, field.to_s, '"text"'], + [:set, field.to_s, '"new text"'] + ] + end + it 'quotes value when setting it' do expect(plot.to_gplot).to eq("set #{field} \"text\"\n") end @@ -12,10 +19,7 @@ expect { plot.public_send(field, 'new text') } .to change(plot, :settings) .from([[:set, field.to_s, '"text"']]) - .to([ - [:set, field.to_s, '"text"'], - [:set, field.to_s, '"new text"'] - ]) + .to(expected_settings) end end end @@ -35,7 +39,6 @@ ].join("\n") end - context 'when nothing has been set' do it "returns an empty string" do expect(plot.to_gplot).to eq('') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 38530b9..e2940fd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -55,57 +55,55 @@ # triggering implicit auto-inclusion in groups with matching metadata. config.shared_context_metadata_behavior = :apply_to_host_groups -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # This allows you to limit a spec run to individual examples or groups - # you care about by tagging them with `:focus` metadata. When nothing - # is tagged with `:focus`, all examples get run. RSpec also provides - # aliases for `it`, `describe`, and `context` that include `:focus` - # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - config.filter_run_when_matching :focus - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ - # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode - config.disable_monkey_patching! - - # This setting enables warnings. It's recommended, but in some cases may - # be too noisy due to issues in dependencies. - config.warnings = true - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = "doc" - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end + # The settings below are suggested to provide a good initial experience + # with RSpec, but feel free to customize to your heart's content. + # # This allows you to limit a spec run to individual examples or groups + # # you care about by tagging them with `:focus` metadata. When nothing + # # is tagged with `:focus`, all examples get run. RSpec also provides + # # aliases for `it`, `describe`, and `context` that include `:focus` + # # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + # config.filter_run_when_matching :focus + # + # # Allows RSpec to persist some state between runs in order to support + # # the `--only-failures` and `--next-failure` CLI options. We recommend + # # you configure your source control system to ignore this file. + # config.example_status_persistence_file_path = "spec/examples.txt" + # + # # Limits the available syntax to the non-monkey patched syntax that is + # # recommended. For more details, see: + # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + # config.disable_monkey_patching! + # + # # This setting enables warnings. It's recommended, but in some cases may + # # be too noisy due to issues in dependencies. + # config.warnings = true + # + # # Many RSpec users commonly either run the entire suite or an individual + # # file, and it's useful to allow more verbose output when running an + # # individual spec file. + # if config.files_to_run.one? + # # Use the documentation formatter for detailed output, + # # unless a formatter has already been configured + # # (e.g. via a command-line flag). + # config.default_formatter = "doc" + # end + # + # # Print the 10 slowest examples and example groups at the + # # end of the spec run, to help surface which specs are running + # # particularly slow. + # config.profile_examples = 10 + # + # # Run specs in random order to surface order dependencies. If you find an + # # order dependency and want to debug it, you can fix the order by providing + # # the seed, which is printed after each run. + # # --seed 1234 + # config.order = :random + # + # # Seed global randomization in this process using the `--seed` CLI option. + # # Setting this allows you to use `--seed` to deterministically reproduce + # # test failures related to randomization by passing the same `--seed` value + # # as the one that triggered the failure. + # Kernel.srand config.seed end diff --git a/spec/support/models/random_generator.rb b/spec/support/models/random_generator.rb index 96e752e..5ad8062 100644 --- a/spec/support/models/random_generator.rb +++ b/spec/support/models/random_generator.rb @@ -12,7 +12,7 @@ def rand def seed(value) @rand = value.abs % 1 - @rand = nil if @rand == 0 + @rand = nil if @rand.zero? end end end From 0ba30730d44c7b17a27847d50cac3efc146778ef Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 27 Nov 2019 09:28:38 +0100 Subject: [PATCH 50/55] Add spec for Plot#style --- .rubocop.yml | 4 ++++ spec/lib/ruby_gnuplot/plot_spec.rb | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 2b2ba5e..be02188 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,3 +7,7 @@ AllCops: RSpec/DescribeClass: Exclude: - 'spec/**/*_spec.rb' + +Metrics/BlockLength: + Exclude: + - 'spec/**/*_spec.rb' diff --git a/spec/lib/ruby_gnuplot/plot_spec.rb b/spec/lib/ruby_gnuplot/plot_spec.rb index 4acdd21..0b2db45 100644 --- a/spec/lib/ruby_gnuplot/plot_spec.rb +++ b/spec/lib/ruby_gnuplot/plot_spec.rb @@ -198,4 +198,23 @@ end end end + + describe '#style' do + subject(:plot) do + described_class.new do |p| + p.title 'My title' + p.style do |style| + style.ls = 1 + end + end + end + + let(:expected_output) do + /^set title "My title"\nset style line \d+ ls 1\n$/ + end + + it 'adds style to gplot output' do + expect(plot.to_gplot).to match(expected_output) + end + end end From 93ba7af80d19fd1968677b8eafc81281853b5f7c Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 27 Nov 2019 09:29:13 +0100 Subject: [PATCH 51/55] Remove TODOs --- spec/lib/ruby_gnuplot/plot_spec.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/lib/ruby_gnuplot/plot_spec.rb b/spec/lib/ruby_gnuplot/plot_spec.rb index 0b2db45..49e4279 100644 --- a/spec/lib/ruby_gnuplot/plot_spec.rb +++ b/spec/lib/ruby_gnuplot/plot_spec.rb @@ -113,7 +113,6 @@ plot.title 'My Title' end - # TODO: check specification it 'changes value in current settings' do expect { plot.unset 'title' } .to change { plot['title'] } @@ -151,7 +150,6 @@ plot.title "My New Title" end - # TODO: check specification it "returns the last value set" do expect(plot['title']).to eq('"My New Title"') end @@ -163,7 +161,6 @@ plot.unset "title" end - # TODO: check specification it { expect(plot['title']).to be_nil } end @@ -174,7 +171,6 @@ plot.title "My New Title" end - # TODO: check specification it "returns the last value set" do expect(plot['title']).to eq('"My New Title"') end From 1564edc4c5cbfbf38302b50a888a5ca917064b03 Mon Sep 17 00:00:00 2001 From: darthjee Date: Wed, 27 Nov 2019 18:20:10 +0100 Subject: [PATCH 52/55] Add data set spec --- spec/lib/ruby_gnuplot/data_set_spec.rb | 55 ++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 spec/lib/ruby_gnuplot/data_set_spec.rb diff --git a/spec/lib/ruby_gnuplot/data_set_spec.rb b/spec/lib/ruby_gnuplot/data_set_spec.rb new file mode 100644 index 0000000..380aaab --- /dev/null +++ b/spec/lib/ruby_gnuplot/data_set_spec.rb @@ -0,0 +1,55 @@ +require 'spec_helper' + +describe Gnuplot::DataSet do + subject(:data_set) { described_class.new(data) } + + describe '#to_gplot' do + context 'when data is an empty array' do + let(:data) { [] } + + it do + expect(data_set.to_gplot).to eq('') + end + end + + context 'when data is an array of numbers' do + let(:data) { [1, 10.0, 2.3] } + + it 'converts to gplot format' do + expect(data_set.to_gplot).to eq("1\n10.0\n2.3") + end + end + + context 'when data is a matrix of numbers' do + let(:data) { [[1, 10.0], [0, 2]] } + + it 'converts to gplot matrix format' do + expect(data_set.to_gplot).to eq("1 0\n10.0 2\ne") + end + end + + context 'when data is a string' do + let(:data) { 'x' } + + it do + expect(data_set.to_gplot).to be_nil + end + end + + context 'when data is an instance of Matrix' do + xit 'to be implemented' + end + + context 'when data is nil' do + let(:data) { nil } + + it do + expect(data_set.to_gplot).to be_nil + end + + it 'assigns data' do + expect(data_set.data).to eq(data) + end + end + end +end From 6decfe0848094128c0d5b6d6cacc45ef53106afb Mon Sep 17 00:00:00 2001 From: darthjee Date: Thu, 28 Nov 2019 22:10:19 +0100 Subject: [PATCH 53/55] Add spec for data set with properties --- spec/lib/ruby_gnuplot/data_set_spec.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/spec/lib/ruby_gnuplot/data_set_spec.rb b/spec/lib/ruby_gnuplot/data_set_spec.rb index 380aaab..a42505f 100644 --- a/spec/lib/ruby_gnuplot/data_set_spec.rb +++ b/spec/lib/ruby_gnuplot/data_set_spec.rb @@ -3,6 +3,8 @@ describe Gnuplot::DataSet do subject(:data_set) { described_class.new(data) } + let(:data) { nil } + describe '#to_gplot' do context 'when data is an empty array' do let(:data) { [] } @@ -41,8 +43,6 @@ end context 'when data is nil' do - let(:data) { nil } - it do expect(data_set.to_gplot).to be_nil end @@ -51,5 +51,20 @@ expect(data_set.data).to eq(data) end end + + context 'when setting attributes' do + subject(:data_set) do + described_class.new do |ds| + ds.with = 'lines' + ds.using = '1:2' + ds.data = [ [0, 1, 2], [1, 2, 5] ] + end + end + + it 'returns only the data' do + expect(data_set.to_gplot) + .to eq("0 1\n1 2\n2 5\ne") + end + end end end From 21fabe5b16658cf7771aaecb9b387c938910240e Mon Sep 17 00:00:00 2001 From: darthjee Date: Thu, 28 Nov 2019 22:25:21 +0100 Subject: [PATCH 54/55] WIP add spec for plot args --- spec/lib/ruby_gnuplot/data_set_spec.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/spec/lib/ruby_gnuplot/data_set_spec.rb b/spec/lib/ruby_gnuplot/data_set_spec.rb index a42505f..efb96f8 100644 --- a/spec/lib/ruby_gnuplot/data_set_spec.rb +++ b/spec/lib/ruby_gnuplot/data_set_spec.rb @@ -52,7 +52,7 @@ end end - context 'when setting attributes' do + context 'when setting attributes in a block' do subject(:data_set) do described_class.new do |ds| ds.with = 'lines' @@ -67,4 +67,23 @@ end end end + + describe '#plot_args' do + context 'when setting attributes on initialize block' do + subject(:data_set) do + described_class.new do |ds| + ds.with = 'lines' + ds.using = '1:2' + ds.data = data + end + end + + let(:data) { [ [0, 1, 2], [1, 2, 5] ] } + + it 'returns plot attributes' do + expect(data_set.plot_args) + .to eq("'-' using 1:2 with lines") + end + end + end end From ac66888a0240b4227248d7f520c25a9ef87a4850 Mon Sep 17 00:00:00 2001 From: Roger Pack Date: Fri, 20 Dec 2019 07:31:31 -0700 Subject: [PATCH 55/55] Update README.textile Note security, thanks Emil --- README.textile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.textile b/README.textile index 4ec5086..3757e4e 100644 --- a/README.textile +++ b/README.textile @@ -16,10 +16,10 @@ h2. History and Background h2. Pre-requisites and Installation - 1. Install XQuartz from here: + 1. (mac) Install XQuartz from here: @http://xquartz.macosforge.org/landing/@ - 2. Install gnuplot with homebrew: + 2. Install gnuplot with homebrew (not OS X? install it using your package manager): @brew install gnuplot --with-x11@ 3. Install gnuplot gem: @@ -188,6 +188,8 @@ File.open( "gnuplot.dat", "w") do |gp| end +h3. Miscellanrous + You can also add arbitrary lines to the output
@@ -196,3 +198,9 @@ plot.arbitrary_lines << "set ylabel \"y label\" font \"Helvetica,20\""
 
 See more in the examples folder.  Also since this is basically just a wrapper for gnuplot itself, you should be able to do anything that it can do (demos: 
 http://gnuplot.sourceforge.net/demo_4.4/ ) 
+
+h3. Security
+
+Note that if you pass any user-controlled strings to the gem, it's possible for an attacker to run arbitrary commands.
+
+In addition to title, any other graph properties that accept strings should be affected too.  they're all passed to the system command.  So only use strings you trust.