gnutemplate 0.1.2 → 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: d8a82a7fe778279fa02fcb58398a374bd7e8a38daf3ce77d37c893620914b9fd
4
- data.tar.gz: aced9c23b6c368788faf7a6346913b7dacfff8768d6210feb50da04c152a32a3
3
+ metadata.gz: 7b32995859d468d838a3c7f476b474c01e63a78b6a83322520e32a8679ba61a4
4
+ data.tar.gz: 4c9c563343a43a41381139321133c4d54ce0149b025a5902552e2f7a85b86bb9
5
5
  SHA512:
6
- metadata.gz: 6590cea51d2c4371d362372d1e7ea7a7a4a6980186a3266916d24be8cadd384945d460b7ca464cf20d173667313908e4303e17872090b7ca15a4d82752b6aca4
7
- data.tar.gz: 8f1883afe227201d8552674a6c4788a3604edbb68306c73b519649e5e517148fc9fdb4261a3dc93078055ca9bf0ab098a834c83bf0bb9fe52946a242ddbda1ae
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.2"
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.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - showata
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: histogram-array
28
+ name: histogram
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="