gnutemplate 0.1.3 → 0.1.4

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: 1571cfebbbc0fa1eb30f8ebfb450d3a127f42c0a4036a66148aa703ea410e0b0
4
- data.tar.gz: a568514c4a150a9abe5ae457a179733bdb5383c9a513b9eb52249a1af70e36dc
3
+ metadata.gz: 7b32995859d468d838a3c7f476b474c01e63a78b6a83322520e32a8679ba61a4
4
+ data.tar.gz: 4c9c563343a43a41381139321133c4d54ce0149b025a5902552e2f7a85b86bb9
5
5
  SHA512:
6
- metadata.gz: 3be04538a1375a47b6101472ed034617a07cebb103036dfea002d29413fa8ec4d20763a7c3a0e18944dd991fa6884f71d36bb5385d454d33a1f2d397382247f2
7
- data.tar.gz: 727928cbe42364cb85840f639164ee4088accbfc0c57a94609aba6471a7cf10b4d239b0cae4e0018650be84e0d323bb27df482c2eaa27f3095a2cd5668ddd66a
6
+ metadata.gz: 7fe81edb3d97e393a8a6ff75aa40359c40bfb6308caafba292d524f76a6c9c5a4ee81e6ab6712ba233b8cc88337079b51debdbcdb7fab6106219cad573676cf3
7
+ data.tar.gz: d6a66f2a88b1a0cd9dc738c3bc26f9d2d2c78dba0f3be755f0ed30052af0ba0a7cd95da01800659f3f03ef2e5c19dc68951bb19288ec45a2d28a02852d93dc12
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gnutemplate
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
data/lib/gnutemplate.rb CHANGED
@@ -65,7 +65,7 @@ module Gnutemplate
65
65
  # X軸はこの場合配列にしなきゃだめ(to_a) これは癖をつけたほうが安全
66
66
 
67
67
  args = rows_min.zip(rows_max, titlenames).each.with_index.inject([]) do |result, ((mi, ma, t), i)|
68
- result += [xrange.to_a, mi, mi, ma, ma, {with: "candlesticks", fc_rgb: colors[i % 4], title: t} ]
68
+ result += [xrange.to_a, mi.to_a, mi.to_a, ma.to_a, ma.to_a, {with: "candlesticks", fc_rgb: colors[i % 4], title: t} ]
69
69
  end
70
70
 
71
71
  plot *args
@@ -105,7 +105,7 @@ module Gnutemplate
105
105
  # X軸はこの場合配列にしなきゃだめ(to_a) これは癖をつけたほうが安全
106
106
 
107
107
  args = rows_min.zip(rows_max, titlenames).each.with_index.inject([]) do |result, ((mi, ma, t), i)|
108
- result += [xrange.to_a, mi, mi, ma, ma, {with: "candlesticks", fc_rgb: colors[i % 4], title: t} ]
108
+ result += [xrange.to_a, mi.to_a, mi.to_a, ma.to_a, ma.to_a, {with: "candlesticks", fc_rgb: colors[i % 4], title: t} ]
109
109
  end
110
110
 
111
111
  plot *args
@@ -114,16 +114,18 @@ module Gnutemplate
114
114
 
115
115
  def note_histogram(data, labels: nil, pileup: true,
116
116
  xmin: nil, xmax: nil, ymin: 0, ymax: nil, bins: 10,
117
- figsize: 1.0, rotate_xtics: nil,
117
+ figsize: 1.0, rotate_xtics: 45,
118
118
  fill: true, alpha: 33, background: nil,
119
119
  file: nil, engine: :note)
120
120
 
121
+ data = [data] if data[0].kind_of?(Numeric) || data[0].nil?
122
+
121
123
  alpha_hex = (alpha * 256 / 100).to_s(16).upcase
122
124
  colors = ["##{alpha_hex}CC0000", "##{alpha_hex}00CC00", "##{alpha_hex}0000CC", "##{alpha_hex}888800"]
123
125
 
124
126
  xmax ||= data.flatten.max
125
127
  xmin ||= data.flatten.min
126
- freqs = data.map {|d| d.histogram(bins, min: xmin, max: xmax) }
128
+ freqs = data.map {|d| d.to_a.histogram(bins, min: xmin, max: xmax) }
127
129
  ymax ||= freqs.map{ _1[1] }.flatten.max * 1.1
128
130
 
129
131
  Numo.noteplot do
@@ -173,7 +175,7 @@ module Gnutemplate
173
175
  set :style, :histogram, :cluster, gap:1
174
176
  set :style, :fill_solid, border:-1
175
177
  set boxwidth:0.9
176
- set :xtic, :rotate, by:-45, scale:0
178
+ set :xtic, :rotate, by: rotate_xtics, scale: 0
177
179
 
178
180
  xticinterval = (xmax-xmin).to_f / bins
179
181
  set xrange: 0..((xmax-xmin) / xticinterval).to_i
@@ -195,16 +197,18 @@ module Gnutemplate
195
197
 
196
198
  def draw_histogram(data, labels: nil, pileup: true,
197
199
  xmin: nil, xmax: nil, ymin: 0, ymax: nil, bins: 10,
198
- figsize: 1.0, rotate_xtics: nil,
200
+ figsize: 1.0, rotate_xtics: 45,
199
201
  fill: true, alpha: 33, background: nil,
200
202
  file: nil, engine: :note)
201
203
 
204
+ data = [data] if data[0].kind_of?(Numeric) || data[0].nil?
205
+
202
206
  alpha_hex = (alpha * 256 / 100).to_s(16).upcase
203
207
  colors = ["##{alpha_hex}CC0000", "##{alpha_hex}00CC00", "##{alpha_hex}0000CC", "##{alpha_hex}888800"]
204
208
 
205
209
  xmax ||= data.flatten.max
206
210
  xmin ||= data.flatten.min
207
- freqs = data.map {|d| d.histogram(bins, min: xmin, max: xmax) }
211
+ freqs = data.map {|d| d.to_a.histogram(bins, min: xmin, max: xmax) }
208
212
  ymax ||= freqs.map{ _1[1] }.flatten.max * 1.1
209
213
 
210
214
  Numo.gnuplot do
@@ -253,7 +257,7 @@ module Gnutemplate
253
257
  set :style, :histogram, :cluster, gap:1
254
258
  set :style, :fill_solid, border:-1
255
259
  set boxwidth:0.9
256
- set :xtic, :rotate, by:-45, scale:0
260
+ set :xtic, :rotate, by: rotate_xtics, scale: 0
257
261
 
258
262
  xticinterval = (xmax-xmin).to_f / bins
259
263
  set xrange: 0..((xmax-xmin) / xticinterval).to_i
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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - showata