From 77bbe535f08a4377a7d86f11a21a726b06470323 Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Mon, 3 Sep 2018 13:55:58 +0200 Subject: [PATCH] Adding entry to CHangeLog to acknowledge Jon Coppeard's change --- eplot | 317 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 159 insertions(+), 158 deletions(-) diff --git a/eplot b/eplot index 300f40e..fa3a226 100755 --- a/eplot +++ b/eplot @@ -1,6 +1,6 @@ #!/usr/bin/ruby # ************************************************************************** -# eplot +# eplot # Written by Christian Wolf # # eplot ("easy gnuplot") is a shell script which allows to pipe data easily @@ -8,22 +8,23 @@ # PDF, PNG, EMF or SVG files. Plotting of multiple files into a single diagram # is supported. # ************************************************************************** -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the -# Free Software Foundation, Inc., -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ************************************************************************** # Changelog: +# 2.09 03.09.2018: -Jon Coppeard added support for SVG (@jonco3 at github) # 2.08 24.07.2017: -added dumb terminal support by Peter Barnes # 2.07 03.05.2007: -bugfix case where input file is empty # 2.06 09.12.2005: -bugfix style not set when single plot from stdin @@ -47,7 +48,7 @@ # -Added some argument checking # 1.04 30.06.2005: -Bugfix option -M when data is piped # -Improved -t option to make multiple titles possible -# 1.0 ??.??.2002: -Start of project, initial version written in +# 1.0 ??.??.2002: -Start of project, initial version written in # UNIX korn shell # ************************************************************************** @@ -68,23 +69,23 @@ $barStyleIndex="20" $help=< Specify the output filename -d --dumb Output to dumb terminal (ascii art) - + Output formatting options: -r set the range of x and y axis values (e.g. -r [5:10][0:100]). @@ -93,14 +94,14 @@ Output formatting options: -l set the type of curve (lines,points,linespoints,...) -w set the line width (default: 1) -x provide x-axis options - --xlog log x-axis + --xlog log x-axis -y provide y-axis options - --ylog log y-axis + --ylog log y-axis -t set the title(s) of the curve(s) (separated by @) -I set the order of the line styles (separated by ,) (e.g. -I "2,1,3,4,5") - -Miscellaneous opions: + +Miscellaneous opions: -B , creates vertical bars (separated by @) e.g. -B 100,0.8@200,0.8 -D --dump dump all used files as "eplot-dump-.dat" @@ -122,7 +123,7 @@ class OptionController # -------------------------------------------------------------------------- # ---- constructor - def initialize(xargv) + def initialize(xargv) @o={} @o["Files"]=[] @o["LineType"]="lines" @@ -139,44 +140,44 @@ class OptionController @o["Ratio"]="" @o["Range"]="" @o["OutputFileDefault"]="" - @o["OutputFileSpecified"]="" - + @o["OutputFileSpecified"]="" + i=0 com="" while i1 com=com+"\""+f.path+"\" " - + # ---- do we have a title? if titleArr if i>titleArr.length @@ -539,31 +540,31 @@ class Controller case titleArr[i-1] when "bar-notitle" com=com+"notitle " - + when "empty-notitle" com=com+"notitle " - + when "default-title" ; else - com=com+"title \""+titleArr[i-1]+"\" " + com=com+"title \""+titleArr[i-1]+"\" " end - end - + end + if titleArr!=nil and titleArr[i-1]=="bar-notitle" com=com+"with impulses ls "+$barStyleIndex else com=com+"with "+@oc["LineType"]+" ls "+styleArr[i-1] end i=i+1 - end + end plot(com,true) end - + # -------------------------------------------------------------------------- # ---- run multiple plots from multiple files # ---- argument: list of filenames - def runMulFrMul(filenames) + def runMulFrMul(filenames) openedFiles=[] filenames.each do |fn| if not FileTest.exist?(fn) @@ -572,11 +573,11 @@ class Controller end t=File.open(fn) openedFiles.push(t) - end + end runMulFrMulOpenedFiles(openedFiles) openedFiles.each { |f| f.close } end - + # -------------------------------------------------------------------------- # ---- run multiple plots from a single file def runMulFrSin(filename) @@ -584,25 +585,25 @@ class Controller # ---- Let's see how many columns we have in the file File.open(filename) { |x| nocols=x.gets.split(" ").length } $stderr.printf "Found %d columns\n",nocols - + # ---- Traverse the columns and put them into seperate files files=[] for i in (1..nocols) tmpf=Tempfile.new("eplot") files.push(tmpf) - extractColumn(filename,i,tmpf) - end - + extractColumn(filename,i,tmpf) + end + # ---- Call it as if we had multiple files removeDummyTitles(files.length) - runMulFrMulOpenedFiles(files) + runMulFrMulOpenedFiles(files) files.each { |f| f.close } end - + # -------------------------------------------------------------------------- # ---- run multiple plots from a single file # ---- one single column, curves are separated by blank lines - def runMulFrSeq(filename) + def runMulFrSeq(filename) files=[] begin file = File.open(filename) @@ -610,23 +611,23 @@ class Controller $stderr.printf "%scannot open file '%s' for reading!\n",$err,filename exit 1 end - - startNewFile=true - oldFile=tmpf=nil + + startNewFile=true + oldFile=tmpf=nil while line=file.gets - + # ---- only whitespace in the line? if line.split(" ").length<1 - startNewFile=true - else + startNewFile=true + else if startNewFile - oldFile.flush if oldFile + oldFile.flush if oldFile tmpf=oldFile=Tempfile.new("eplot") files.push(tmpf) startNewFile=false - end - tmpf.puts line - end + end + tmpf.puts line + end end if tmpf tmpf.flush @@ -635,31 +636,31 @@ class Controller exit 1 end file.close - + # ---- Call it as if we had multiple files removeDummyTitles(files.length) - runMulFrMulOpenedFiles(files) + runMulFrMulOpenedFiles(files) files.each { |f| f.close } end - + # -------------------------------------------------------------------------- - # ---- run from a single file. + # ---- run from a single file. # ---- either a single or multiple diagrams - def runFrOneOrMoreFiles(filenames) + def runFrOneOrMoreFiles(filenames) # ---- Multiple curves in a single diagram from a single file # ---- or repeated across multiple files - if @oc["MulFrSin"] - filenames.each { |fn| runMulFrSin(fn) } - - else - # ---- Multiple curves in a single diagram from different files - if @oc["MulFrMul"] + if @oc["MulFrSin"] + filenames.each { |fn| runMulFrSin(fn) } + + else + # ---- Multiple curves in a single diagram from different files + if @oc["MulFrMul"] runMulFrMul(filenames) - + else if @oc["MulFrSeq"] - filenames.each { |fn| runMulFrSeq(fn) } - + filenames.each { |fn| runMulFrSeq(fn) } + # ---- Default: a separate curve for each file else filenames.each { |fn| runSinFrSin(fn) } @@ -673,20 +674,20 @@ class Controller def runFrStdin tmpf=Tempfile.new("eplot") $stdin.each_line { |x| tmpf.print x } - tmpf.flush - + tmpf.flush + runFrOneOrMoreFiles([tmpf.path]) tmpf.close - end - + end + # -------------------------------------------------------------------------- # ---- run the application - def run + def run # ---- run from stdin if @oc["Files"].length < 1 - runFrStdin + runFrStdin # ---- run from a given file list - else + else runFrOneOrMoreFiles(@oc["Files"]) end end