gnutemplate 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fef32d38de9aac460a3999b100fedb69ffa1a95a72589fc196b4dc34385e1bf
4
- data.tar.gz: 3ff03c9032f496344d52b28f99e25e6f7440e31b8a617e292871123d0fced7c4
3
+ metadata.gz: 5faac0acbe5d64d0e9cf6aec58ffed06004f62e0c372ef4a551881de916e2c64
4
+ data.tar.gz: b2676c4052f26536e59c5e34379e67fb7f7013f3ca40479088342aa0ae71e7c6
5
5
  SHA512:
6
- metadata.gz: c6af589bee0cd490502d19f180a5929af1633bd6aae0441856fb8ad7cf3e5de945ecaac27171f31c6e29ba18a668f5784b0036a091a45e6826ca6d2da828fc34
7
- data.tar.gz: 466d9643c0fdb0e0697a4afc445da81c1d450dbde07550a62d19ce22e0ac398ac4a3c725454a4a7bd09502f01f980bc963fdcae59c8d404be34d49e055c26a46
6
+ metadata.gz: 28dd05eeaa1cda84b9fcca9d0eb537af4e884e103e7b2b9e80314350dbe32c97a0504902af8d9e4f3f1555579afee54947bf404955d05b62fa82b47717591bcb
7
+ data.tar.gz: a7413b695ff3273cd126c1beb0b477b4f81e53a0ad573b89008566401e2408f161bd3f62151cc8ec1037efd798ae074865e52a3e90f9958bf058472480b51114
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gnutemplate
4
- VERSION = "0.1.9"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/gnutemplate.rb CHANGED
@@ -143,11 +143,6 @@ module Gnutemplate
143
143
  fill: true, alpha: 33, background: nil,
144
144
  file: nil)
145
145
 
146
- if !file.nil?
147
- set terminal: "gif"
148
- set output: file
149
- end
150
-
151
146
  data = [data] if data[0].kind_of?(Numeric) || data[0].nil?
152
147
 
153
148
  alpha_hex = (alpha * 256 / 100).to_s(16).upcase
@@ -185,7 +180,7 @@ module Gnutemplate
185
180
  end
186
181
  end
187
182
 
188
- plot *args
183
+ return args
189
184
 
190
185
  else
191
186
 
@@ -215,7 +210,7 @@ module Gnutemplate
215
210
  [*f, using: 2, w: :histogram, t: labels[i], fillcolor: "rgb \"#{colors[i % 4]}\""]
216
211
  end
217
212
 
218
- plot *args
213
+ return args
219
214
 
220
215
  end # Of if pileup..else
221
216
  end
@@ -228,81 +223,90 @@ module Gnutemplate
228
223
 
229
224
  Numo.noteplot do
230
225
 
231
- data = [data] if data[0].kind_of?(Numeric) || data[0].nil?
232
-
233
- alpha_hex = (alpha * 256 / 100).to_s(16).upcase
234
- colors = ["##{alpha_hex}CC0000", "##{alpha_hex}00CC00", "##{alpha_hex}0000CC", "##{alpha_hex}888800"]
235
-
236
- xmax ||= data.map(&:to_a).flatten.compact.max
237
- xmin ||= data.map(&:to_a).flatten.compact.min
238
- freqs = data.map {|d| d.to_a.compact.histogram(bins, min: xmin, max: xmax) }
239
- ymax ||= freqs.map{ _1[1] }.flatten.max * 1.1
240
-
241
226
  if !file.nil?
242
227
  set terminal: "gif"
243
228
  set output: file
244
229
  end
230
+
231
+ args = histogram(data, labels: labels, pileup: pileup,
232
+ xmin: xmin, xmax: xmax, ymin: ymin, ymax: ymax, bins: bins,
233
+ figsize: figsize, rotate_xtics: rotate_xtics,
234
+ fill: fill, alpha: alpha, background: background)
235
+
236
+ plot *args
245
237
 
246
- if pileup
247
- ###########
248
- ###
249
- ###########
238
+ # data = [data] if data[0].kind_of?(Numeric) || data[0].nil?
250
239
 
251
- set size: "#{figsize},#{figsize}"
252
- set style: "fill solid" if fill
240
+ # alpha_hex = (alpha * 256 / 100).to_s(16).upcase
241
+ # colors = ["##{alpha_hex}CC0000", "##{alpha_hex}00CC00", "##{alpha_hex}0000CC", "##{alpha_hex}888800"]
242
+
243
+ # xmax ||= data.map(&:to_a).flatten.compact.max
244
+ # xmin ||= data.map(&:to_a).flatten.compact.min
245
+ # freqs = data.map {|d| d.to_a.compact.histogram(bins, min: xmin, max: xmax) }
246
+ # ymax ||= freqs.map{ _1[1] }.flatten.max * 1.1
253
247
 
254
- xticinterval = (xmax-xmin).to_f / bins
255
- set xtics: "#{xmin-xticinterval}, #{xticinterval}, #{xmax+xticinterval}"
256
- set(:xtics, "rotate by #{rotate_xtics}") if rotate_xtics
257
248
 
258
- set xrange: (xmin-xticinterval)..(xmax+xticinterval)
259
- set yrange: ymin..ymax
249
+ # if pileup
250
+ # ###########
251
+ # ###
252
+ # ###########
260
253
 
261
- args = background ? ["[#{xmin}:#{xmax}] #{ymax} with filledc above y=#{ymin} fc \"##{background}\" notitle", {}] : []
254
+ # set size: "#{figsize},#{figsize}"
255
+ # set style: "fill solid" if fill
262
256
 
263
- freqs.each_with_index do |f, i|
264
- args.push f[0], f[1]
257
+ # xticinterval = (xmax-xmin).to_f / bins
258
+ # set xtics: "#{xmin-xticinterval}, #{xticinterval}, #{xmax+xticinterval}"
259
+ # set(:xtics, "rotate by #{rotate_xtics}") if rotate_xtics
265
260
 
266
- if labels
267
- args.push({:with => :boxes, :title => labels[i], :fillcolor => "rgb \"#{colors[i % 4]}\""})
268
- else
269
- args.push({:with => :boxes, :fillcolor => "rgb \"#{colors[i % 4]}\""})
270
- end
271
- end
261
+ # set xrange: (xmin-xticinterval)..(xmax+xticinterval)
262
+ # set yrange: ymin..ymax
272
263
 
273
- plot *args
264
+ # args = background ? ["[#{xmin}:#{xmax}] #{ymax} with filledc above y=#{ymin} fc \"##{background}\" notitle", {}] : []
274
265
 
275
- else
266
+ # freqs.each_with_index do |f, i|
267
+ # args.push f[0], f[1]
276
268
 
277
- ###########
278
- ###
279
- ###########
280
- # set title:"Temperature"
281
- set auto:"x"
282
- set :style, :data, :histogram
283
- set :style, :histogram, :cluster, gap:1
284
- set :style, :fill, solid: 1.0 - (alpha/100.0), border:-1
285
- set boxwidth:0.9
286
- set :xtic, :rotate, by: rotate_xtics, scale: 0
269
+ # if labels
270
+ # args.push({:with => :boxes, :title => labels[i], :fillcolor => "rgb \"#{colors[i % 4]}\""})
271
+ # else
272
+ # args.push({:with => :boxes, :fillcolor => "rgb \"#{colors[i % 4]}\""})
273
+ # end
274
+ # end
287
275
 
288
- xticinterval = (xmax-xmin).to_f / bins
289
- set xrange: 0..((xmax-xmin) / xticinterval).to_i
276
+ # plot *args
290
277
 
291
- xtics = freqs[0][0]
292
- .each.with_index
293
- .inject("(") { |result, (x, i)| result += "'#{x-xticinterval/2}-#{x+xticinterval/2}' #{i}," }
294
- .gsub(/,$/, ")")
295
- set xtics: xtics
278
+ # else
296
279
 
297
- labels ||= (0...(freqs.length)).map(&:to_s)
280
+ # ###########
281
+ # ###
282
+ # ###########
283
+ # # set title:"Temperature"
284
+ # set auto:"x"
285
+ # set :style, :data, :histogram
286
+ # set :style, :histogram, :cluster, gap:1
287
+ # set :style, :fill, solid: 1.0 - (alpha/100.0), border:-1
288
+ # set boxwidth:0.9
289
+ # set :xtic, :rotate, by: rotate_xtics, scale: 0
298
290
 
299
- args = freqs.zip(labels).each_with_index.map do |(f, l), i|
300
- [*f, using: 2, w: :histogram, t: labels[i], fillcolor: "rgb \"#{colors[i % 4]}\""]
301
- end
291
+ # xticinterval = (xmax-xmin).to_f / bins
292
+ # set xrange: 0..((xmax-xmin) / xticinterval).to_i
293
+
294
+ # xtics = freqs[0][0]
295
+ # .each.with_index
296
+ # .inject("(") { |result, (x, i)| result += "'#{x-xticinterval/2}-#{x+xticinterval/2}' #{i}," }
297
+ # .gsub(/,$/, ")")
298
+ # set xtics: xtics
299
+
300
+ # labels ||= (0...(freqs.length)).map(&:to_s)
302
301
 
303
- plot *args
302
+ # args = freqs.zip(labels).each_with_index.map do |(f, l), i|
303
+ # [*f, using: 2, w: :histogram, t: labels[i], fillcolor: "rgb \"#{colors[i % 4]}\""]
304
+ # end
305
+
306
+ # plot *args
307
+
308
+ # end # Of if pileup..else
304
309
 
305
- end # Of if pileup..else
306
310
  end # Of Numo.noteplot do
307
311
 
308
312
  end # Of def function
@@ -313,83 +317,90 @@ module Gnutemplate
313
317
  fill: true, alpha: 33, background: nil,
314
318
  file: nil)
315
319
 
316
- data = [data] if data[0].kind_of?(Numeric) || data[0].nil?
317
-
318
- alpha_hex = (alpha * 256 / 100).to_s(16).upcase
319
- colors = ["##{alpha_hex}CC0000", "##{alpha_hex}00CC00", "##{alpha_hex}0000CC", "##{alpha_hex}888800"]
320
-
321
- xmax ||= data.map(&:to_a).flatten.compact.max
322
- xmin ||= data.map(&:to_a).flatten.compact.min
323
- freqs = data.map {|d| d.to_a.compact.histogram(bins, min: xmin, max: xmax) }
324
- ymax ||= freqs.map{ _1[1] }.flatten.max * 1.1
325
-
326
320
  Numo.gnuplot do
327
321
 
328
322
  if !file.nil?
329
323
  set terminal: "gif"
330
324
  set output: file
331
325
  end
326
+
327
+ args = histogram(data, labels: labels, pileup: pileup,
328
+ xmin: xmin, xmax: xmax, ymin: ymin, ymax: ymax, bins: bins,
329
+ figsize: figsize, rotate_xtics: rotate_xtics,
330
+ fill: fill, alpha: alpha, background: background)
332
331
 
333
- if pileup
334
- ###########
335
- ###
336
- ###########
332
+ plot *args
337
333
 
338
- set size: "#{figsize},#{figsize}"
339
- set style: "fill solid" if fill
334
+ # data = [data] if data[0].kind_of?(Numeric) || data[0].nil?
340
335
 
341
- xticinterval = (xmax-xmin).to_f / bins
342
- set xtics: "#{xmin-xticinterval}, #{xticinterval}, #{xmax+xticinterval}"
343
- set(:xtics, "rotate by #{rotate_xtics}") if rotate_xtics
336
+ # alpha_hex = (alpha * 256 / 100).to_s(16).upcase
337
+ # colors = ["##{alpha_hex}CC0000", "##{alpha_hex}00CC00", "##{alpha_hex}0000CC", "##{alpha_hex}888800"]
338
+
339
+ # xmax ||= data.map(&:to_a).flatten.compact.max
340
+ # xmin ||= data.map(&:to_a).flatten.compact.min
341
+ # freqs = data.map {|d| d.to_a.compact.histogram(bins, min: xmin, max: xmax) }
342
+ # ymax ||= freqs.map{ _1[1] }.flatten.max * 1.1
344
343
 
345
- set xrange: (xmin-xticinterval)..(xmax+xticinterval)
346
- set yrange: ymin..ymax
344
+ # if pileup
345
+ # ###########
346
+ # ###
347
+ # ###########
347
348
 
348
- args = background ? ["[#{xmin}:#{xmax}] #{ymax} with filledc above y=#{ymin} fc \"##{background}\" notitle", {}] : []
349
+ # set size: "#{figsize},#{figsize}"
350
+ # set style: "fill solid" if fill
349
351
 
350
- freqs.each_with_index do |f, i|
351
- args.push f[0], f[1]
352
+ # xticinterval = (xmax-xmin).to_f / bins
353
+ # set xtics: "#{xmin-xticinterval}, #{xticinterval}, #{xmax+xticinterval}"
354
+ # set(:xtics, "rotate by #{rotate_xtics}") if rotate_xtics
352
355
 
353
- if labels
354
- args.push({:with => :boxes, :title => labels[i], :fillcolor => "rgb \"#{colors[i % 4]}\""})
355
- else
356
- args.push({:with => :boxes, :fillcolor => "rgb \"#{colors[i % 4]}\""})
357
- end
358
- end
356
+ # set xrange: (xmin-xticinterval)..(xmax+xticinterval)
357
+ # set yrange: ymin..ymax
359
358
 
360
- plot *args # ,xs, ys, { with: :lines , title: "STD"}
359
+ # args = background ? ["[#{xmin}:#{xmax}] #{ymax} with filledc above y=#{ymin} fc \"##{background}\" notitle", {}] : []
361
360
 
362
- else
361
+ # freqs.each_with_index do |f, i|
362
+ # args.push f[0], f[1]
363
363
 
364
- ###########
365
- ###
366
- ###########
367
- set auto:"x"
368
- set :style, :data, :histogram
369
- set :style, :histogram, :cluster, gap:1
370
- set :style, :fill, solid: 1.0 - (alpha/100.0), border:-1
371
- set boxwidth:0.9
372
- set :xtic, :rotate, by: rotate_xtics, scale: 0
364
+ # if labels
365
+ # args.push({:with => :boxes, :title => labels[i], :fillcolor => "rgb \"#{colors[i % 4]}\""})
366
+ # else
367
+ # args.push({:with => :boxes, :fillcolor => "rgb \"#{colors[i % 4]}\""})
368
+ # end
369
+ # end
373
370
 
374
- xticinterval = (xmax-xmin).to_f / bins
375
- set xrange: 0..((xmax-xmin) / xticinterval).to_i
371
+ # plot *args # ,xs, ys, { with: :lines , title: "STD"}
376
372
 
377
- xtics = freqs[0][0]
378
- .each.with_index
379
- .inject("(") { |result, (x, i)| result += "'#{x-xticinterval/2}-#{x+xticinterval/2}' #{i}," }
380
- .gsub(/,$/, ")")
381
- set xtics: xtics
373
+ # else
382
374
 
383
- labels ||= (0...(freqs.length)).map(&:to_s)
375
+ # ###########
376
+ # ###
377
+ # ###########
378
+ # set auto:"x"
379
+ # set :style, :data, :histogram
380
+ # set :style, :histogram, :cluster, gap:1
381
+ # set :style, :fill, solid: 1.0 - (alpha/100.0), border:-1
382
+ # set boxwidth:0.9
383
+ # set :xtic, :rotate, by: rotate_xtics, scale: 0
384
384
 
385
- args = freqs.zip(labels).each_with_index.map do |(f, l), i|
386
- [*f, using: 2, w: :histogram, t: labels[i], fillcolor: "rgb \"#{colors[i % 4]}\""]
387
- end
385
+ # xticinterval = (xmax-xmin).to_f / bins
386
+ # set xrange: 0..((xmax-xmin) / xticinterval).to_i
388
387
 
389
- plot *args
388
+ # xtics = freqs[0][0]
389
+ # .each.with_index
390
+ # .inject("(") { |result, (x, i)| result += "'#{x-xticinterval/2}-#{x+xticinterval/2}' #{i}," }
391
+ # .gsub(/,$/, ")")
392
+ # set xtics: xtics
393
+
394
+ # labels ||= (0...(freqs.length)).map(&:to_s)
395
+
396
+ # args = freqs.zip(labels).each_with_index.map do |(f, l), i|
397
+ # [*f, using: 2, w: :histogram, t: labels[i], fillcolor: "rgb \"#{colors[i % 4]}\""]
398
+ # end
399
+
400
+ # plot *args
390
401
 
391
- end # Of if pileup..else
392
- end # Of Numo.noteplot do
402
+ # end # Of if pileup..else
403
+ end # Of Numo.gnuplot do
393
404
 
394
405
  end # Of def function
395
406
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gnutemplate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - showata