gnutemplate 0.1.9 → 0.2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gnutemplate/version.rb +1 -1
- data/lib/gnutemplate.rb +129 -118
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f7582d157b2dacffbd2e11ea5b8a6467af3b88f911119e7d0596244e47a75a7
|
4
|
+
data.tar.gz: 15b96ccd899342aeac9f20dbf075ceebb56cd475a32f2753f35e10ef7cc7dc9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: face27d0ec1b486841b3ff35ccb67ee90c3750f55ce3b8aef154521ff536c246b1d6de8279b4e7d9924fee4679c62ea5f3dd1b858ac37220d40c82457e8a1b3f
|
7
|
+
data.tar.gz: 497d5aaf03598153f560037c6f6ed842a17abf41f28fb41559bdc9a56774bb4aa115d1dcb9cc56f07e05baa51b7c27854d13c268e7375363d57c7a2738e9f942
|
data/lib/gnutemplate/version.rb
CHANGED
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
|
-
|
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
|
-
|
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
|
247
|
-
###########
|
248
|
-
###
|
249
|
-
###########
|
238
|
+
# data = [data] if data[0].kind_of?(Numeric) || data[0].nil?
|
250
239
|
|
251
|
-
|
252
|
-
|
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
|
-
|
259
|
-
|
249
|
+
# if pileup
|
250
|
+
# ###########
|
251
|
+
# ###
|
252
|
+
# ###########
|
260
253
|
|
261
|
-
|
254
|
+
# set size: "#{figsize},#{figsize}"
|
255
|
+
# set style: "fill solid" if fill
|
262
256
|
|
263
|
-
|
264
|
-
|
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
|
-
|
267
|
-
|
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
|
-
|
264
|
+
# args = background ? ["[#{xmin}:#{xmax}] #{ymax} with filledc above y=#{ymin} fc \"##{background}\" notitle", {}] : []
|
274
265
|
|
275
|
-
|
266
|
+
# freqs.each_with_index do |f, i|
|
267
|
+
# args.push f[0], f[1]
|
276
268
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
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
|
-
|
289
|
-
set xrange: 0..((xmax-xmin) / xticinterval).to_i
|
276
|
+
# plot *args
|
290
277
|
|
291
|
-
|
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
|
-
|
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
|
-
|
300
|
-
|
301
|
-
|
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
|
-
|
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,85 +317,92 @@ 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
|
-
|
334
|
-
###########
|
335
|
-
###
|
336
|
-
###########
|
332
|
+
plot *args
|
337
333
|
|
338
|
-
|
339
|
-
set style: "fill solid" if fill
|
334
|
+
# data = [data] if data[0].kind_of?(Numeric) || data[0].nil?
|
340
335
|
|
341
|
-
|
342
|
-
|
343
|
-
|
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
|
-
|
346
|
-
|
344
|
+
# if pileup
|
345
|
+
# ###########
|
346
|
+
# ###
|
347
|
+
# ###########
|
347
348
|
|
348
|
-
|
349
|
+
# set size: "#{figsize},#{figsize}"
|
350
|
+
# set style: "fill solid" if fill
|
349
351
|
|
350
|
-
|
351
|
-
|
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
|
-
|
354
|
-
|
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
|
-
|
359
|
+
# args = background ? ["[#{xmin}:#{xmax}] #{ymax} with filledc above y=#{ymin} fc \"##{background}\" notitle", {}] : []
|
361
360
|
|
362
|
-
|
361
|
+
# freqs.each_with_index do |f, i|
|
362
|
+
# args.push f[0], f[1]
|
363
363
|
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
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
|
-
|
375
|
-
set xrange: 0..((xmax-xmin) / xticinterval).to_i
|
371
|
+
# plot *args # ,xs, ys, { with: :lines , title: "STD"}
|
376
372
|
|
377
|
-
|
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
|
-
|
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
|
-
|
386
|
-
|
387
|
-
end
|
385
|
+
# xticinterval = (xmax-xmin).to_f / bins
|
386
|
+
# set xrange: 0..((xmax-xmin) / xticinterval).to_i
|
388
387
|
|
389
|
-
|
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.
|
402
|
+
# end # Of if pileup..else
|
403
|
+
end # Of Numo.gnuplot do
|
393
404
|
|
394
405
|
end # Of def function
|
395
406
|
|
396
|
-
module_function :note_line, :draw_line, :note_box, :draw_box, :note_histogram, :draw_histogram
|
407
|
+
module_function :note_line, :draw_line, :note_box, :draw_box, :histogram, :note_histogram, :draw_histogram
|
397
408
|
end # Of module
|