numo-gnuplot 0.1.5 → 0.1.6
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/README.md +19 -0
- data/examples/ex007.rb +11 -0
- data/lib/numo/gnuplot.rb +30 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23318f9476abeabe7f3b1cf973750b8a6e4a84b0
|
4
|
+
data.tar.gz: 94534cf81c5e11030deddebfa2ff4507dc35ee2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f9e70d4c27142494d857a0fba1ae7c0a3bdd8d9f31095a18c8a08621d309275067224a519eac14218c168a5a8b684ea559d0c99d9405737d5b7be6bb6894632
|
7
|
+
data.tar.gz: a90ac0f94296c4828317087d408b64c408233cd7c84ed9da8956ca9fc29add975712d2af9378fa3cb89340d9ea509831825f40758f1d1c12ecf6c007ccae0da6
|
data/README.md
CHANGED
@@ -153,6 +153,25 @@ Numo.gnuplot do
|
|
153
153
|
end
|
154
154
|
```
|
155
155
|
|
156
|
+
### IRuby
|
157
|
+
Numo::Gnuplot is compatible with [IRuby](https://github.com/SciRuby/iruby/).
|
158
|
+
|
159
|
+
* Embedding a plot into iRuby Notebook.
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
Numo::Gnuplot::NotePlot.new do
|
163
|
+
plot "sin(x)"
|
164
|
+
end
|
165
|
+
```
|
166
|
+
|
167
|
+
* The same thing in short.
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
Numo.noteplot do
|
171
|
+
plot "sin(x)"
|
172
|
+
end
|
173
|
+
```
|
174
|
+
|
156
175
|
## Gnuplot methods
|
157
176
|
|
158
177
|
Numo::Gnuplot class methods succeeded from Gnuplot commands:
|
data/examples/ex007.rb
ADDED
data/lib/numo/gnuplot.rb
CHANGED
@@ -9,9 +9,14 @@ module Numo
|
|
9
9
|
end
|
10
10
|
module_function :gnuplot
|
11
11
|
|
12
|
+
def noteplot(&block)
|
13
|
+
Gnuplot::NotePlot.new(&block)
|
14
|
+
end
|
15
|
+
module_function :noteplot
|
16
|
+
|
12
17
|
class Gnuplot
|
13
18
|
|
14
|
-
VERSION = "0.1.
|
19
|
+
VERSION = "0.1.6"
|
15
20
|
POOL = []
|
16
21
|
DATA_FORMAT = "%.7g"
|
17
22
|
|
@@ -21,6 +26,29 @@ class Gnuplot
|
|
21
26
|
POOL[0] ||= self.new
|
22
27
|
end
|
23
28
|
|
29
|
+
class NotePlot
|
30
|
+
def initialize(&block)
|
31
|
+
if block.nil?
|
32
|
+
raise ArgumentError,"block is needed"
|
33
|
+
end
|
34
|
+
@block = block
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_iruby
|
38
|
+
require 'tempfile'
|
39
|
+
tempfile_svg = Tempfile.open('plot')
|
40
|
+
# output SVG to tmpfile
|
41
|
+
gp = Gnuplot.default
|
42
|
+
gp.reset
|
43
|
+
gp.set terminal:'svg', output:tempfile_svg.path
|
44
|
+
gp.instance_eval(&@block)
|
45
|
+
gp.unset 'output'
|
46
|
+
svg = File.read(tempfile_svg.path)
|
47
|
+
tempfile_svg.close
|
48
|
+
["image/svg+xml",svg]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
24
52
|
def initialize(gnuplot_command="gnuplot")
|
25
53
|
@history = []
|
26
54
|
@debug = false
|
@@ -554,7 +582,7 @@ class Gnuplot
|
|
554
582
|
s = v.to_s
|
555
583
|
if /"/ =~ s
|
556
584
|
kernel_raise GnuplotError,"should not include double quotation in data"
|
557
|
-
|
585
|
+
else
|
558
586
|
s = '"'+s+'"'
|
559
587
|
end
|
560
588
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: numo-gnuplot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro TANAKA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- examples/ex004.rb
|
58
58
|
- examples/ex005.rb
|
59
59
|
- examples/ex006.rb
|
60
|
+
- examples/ex007.rb
|
60
61
|
- examples/ex010.rb
|
61
62
|
- examples/ex011.rb
|
62
63
|
- lib/numo/gnuplot.rb
|