GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — oorexx-gnuplot/Gnuplot.rex at main · sparrac/oorexx-gnuplot Expand file tree/ Copy pathGnuplot.rexMore file actions executable file ·267 lines (210 loc) · 5.99 KB / Copy pathGnuplot.rexFile metadata and controlsexecutable file ·267 lines (210 loc) · 5.99 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 /* * Library: oorexx-gnuplot: gnuplot for ooRexx * File: Gnuplot.rex * Description: An object-oriented wrapper for Gnuplot in Open Object Rexx. * Provides a simple interface to generate 2D/3D plots from data * series (functions, arrays, files), configure output terminals * and export to graphic formats. * * Author: Salvador Parra Camacho * Version: 0.1.1 * Date('S'): 20260831 * License: Apache 2.0 * Repository: https://github.com/sparrac/oorexx-gnuplot */ ::class Gnuplot public ::constant VERSION "0.1.1" ::constant LIBRARY "oorexx-gnuplot" ::method terminals attribute class ::method persist attribute private class ::method iswindows attribute private class ::method init class t = .Directory~new t~png = 'pngcairo enhanced' t~svg = 'svg dashed enhanced' t~pdf = 'pdfcairo linewidth 4 rounded fontscale 1.0' t~wxt = 'wxt enhanced' t~qt = 'qt enhanced' t~html = 'canvas' self~terminals = t p = .Directory~new p~wxt = .true p~qt = .true self~persist = p parse source opsys . . self~iswindows = opsys~upper~abbrev('WINDOWS') ::method bin attribute -- gnuplot executable path ::method plots attribute -- array of plots ::method debug attribute -- debug option ::method constants attribute -- array of constants ::method persist attribute -- gnuplot persist option ::method title attribute -- figure title ::method key attribute -- figure key ::method grid attribute -- figure grid ::method width attribute -- figure width ::method height attribute -- figure height ::method xlabel attribute -- figure x label (bottom) ::method x2label attribute -- figure x label (top) ::method ylabel attribute -- figure y label (left) ::method y2label attribute -- figure y label (right) ::method terminal attribute ::method init self~bin = 'gnuplot' self~plots = .Array~new self~debug = .false self~constants = .Directory~new self~persist = .true self~title = .nil self~key = 'top left' self~grid = .nil self~width = .nil self~height = .nil self~xlabel = .nil self~x2label = .nil self~ylabel = .nil self~y2label = .nil self~terminal = .nil self~output = .nil ::method output expose output return output ::method 'output=' expose output use arg out output = out if out = .nil then return dot_pos = out~lastpos('.') if dot_pos > 1 then do out_extension = out~substr(out~lastpos('.') + 1)~upper if self~class~terminals~hasindex(out_extension) then do self~terminal = self~class~terminals~at(out_extension) self~persist = self~class~persist~at(out_extension) end end ::method add series = .Directory~new series~function = .nil series~data = .nil series~file = .nil series~using = .nil select when arg(1)~isInstanceOf(.String) then series~function = arg(1) when arg(1)~isInstanceOf(.Array) then do series~data = arg(1, 'A') series~using = '1:2' end when arg(1)~isInstanceOf(.Stream) then series~file = arg(1)~string when arg(1)~isInstanceOf(.File) then series~file = arg(1)~absolutePath otherwise nop end series~title = .nil series~width = .nil series~with = .nil series~color = .nil index = self~plots~append(series) return self~plots[index] ::method script private use arg cmd s = .Array~new s~append('# start of gnuplot script') quote_opt = .Directory~new quote_opt['title'] = .true quote_opt['key'] = .false quote_opt['grid'] = .false quote_opt['width'] = .false quote_opt['height'] = .false quote_opt['xlabel'] = .true quote_opt['x2label'] = .true quote_opt['ylabel'] = .true quote_opt['y2label'] = .true quote_opt['terminal'] = .false quote_opt['output'] = .true -- Add gnuplot constants do i over self~constants s~append(i '=' self~constants~at(i)) end -- Add plot options do opt over quote_opt val = self~send(opt) if val = .nil then iterate if quote_opt~at(opt) then s~append('set' opt quote(val)) -- quoted else s~append('set' opt val) -- non quoted end -- Add plot command do p over self~plots select when p~data <> .nil then cmd = cmd '"-" using' p~using when p~function <> .nil then cmd = cmd p~function when p~file <> .nil then cmd = cmd quote(translate(p~file, '/', '\')) otherwise nop end if p~title <> .nil then cmd = cmd 'title' quote(p~title) if p~width <> .nil then cmd = cmd 'lw' p~width if p~with <> .nil then cmd = cmd 'w' p~with if p~color <> .nil then cmd = cmd 'lc' p~color cmd = cmd || ',' end cmd = cmd~strip('T', ',') s~append(cmd) -- Add data (if any) plots = self~plots do p over plots if p~data = .nil then iterate s~append('# start of data') do i = 1 to p~data[1]~items line = '' do column over p~data line = line column[i] end s~append(line) end s~append('e # end of data') end s~append('# end of gnuplot script' || .endofline) return s~makestring -- return string with contents of script ::method plot if \arg(1, 'O') then self~output = arg(1) return self~runplot('plot') ::method splot if \arg(1, 'O') then self~output = arg(1) return self~runplot('splot') ::method runplot private parse arg cmd if self~class~iswindows then path = value('TEMP', , 'ENVIRONMENT') || '\' else path = '' scriptname = SysTempFileName(path || 'gnuplot.???') script = self~script(cmd) if self~debug then .error~charout(script) call lineout scriptname, script call lineout scriptname if self~persist = .true then persist = '-persist' else persist = '' quoted_script = '"' || scriptname || '"' if self~class~iswindows then start = 'start /B' else start = '' start self~bin persist quoted_script if \ self~class~iswindows then call SysFileDelete scriptname return rc ::routine quote use arg s return "'" || s || "'" |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |