unifiedPlot 0.0.3 → 0.0.4
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/gemspec +1 -1
- data/lib/unifiedPlot.rb +71 -34
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 304311035a530de07e6cafc0ec9ceadacb004fe9
|
4
|
+
data.tar.gz: ec01987014080b3bcb05ad1e0256c5f503975c21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bdbb5432b3d625b72aee36a41043aa3840e6890a38bdd0c772f9e373a6f556f4307d216086c6d5dd5523fa280e1b174ee09c8b2029b41bd4da6bbd10ef57a4c
|
7
|
+
data.tar.gz: cb08346500cfbddf704a9bb79889833c0c8d4317d4b09991d57a74a8002f25606195094350a1817c7ade4ef3a0cb0ad33bb3437f45c3e8dbd9cddc6a66375e67
|
data/gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
GEM_SPEC = Gem::Specification.new do |s|
|
4
4
|
s.name = "unifiedPlot"
|
5
|
-
s.version = '0.0.
|
5
|
+
s.version = '0.0.4'
|
6
6
|
s.date = Time.new.strftime("%Y-%m-%d")
|
7
7
|
|
8
8
|
s.description = 'single interface to line-plotting data in [],NArray and GSL::Vector format'
|
data/lib/unifiedPlot.rb
CHANGED
@@ -10,7 +10,7 @@ module UnifiedPlot
|
|
10
10
|
:y2label => nil,
|
11
11
|
:xlabel => nil,
|
12
12
|
:x2label => nil,
|
13
|
-
:
|
13
|
+
:key => 'bottom out',
|
14
14
|
:xsize => 1200,
|
15
15
|
:ysize => 800,
|
16
16
|
:font => 'arial',
|
@@ -35,36 +35,25 @@ module UnifiedPlot
|
|
35
35
|
# :title => '',
|
36
36
|
# :grid => false,
|
37
37
|
# }
|
38
|
-
def UnifiedPlot.setPlotDefaults(plot,plotConf,title,oType,oName)
|
39
|
-
plotConf = PLOT_DEFAULTS.merge(plotConf)
|
40
|
-
unless 'x11' == oType
|
41
|
-
plot.terminal "#{oType} size #{plotConf[:xsize]},#{plotConf[:ysize]} font #{plotConf[:font]} #{plotConf[:fontsize]}"
|
42
|
-
plot.output "#{oName}.#{oType}"
|
43
|
-
end
|
44
|
-
plot.title title
|
45
|
-
plot.key plotConf[:label_position]
|
46
|
-
|
47
|
-
plot.xrange plotConf[:xrange] unless plotConf[:xrange].nil?
|
48
|
-
plot.x2range plotConf[:x2range] unless plotConf[:x2range].nil?
|
49
|
-
plot.yrange plotConf[:yrange] unless plotConf[:yrange].nil?
|
50
|
-
plot.y2range plotConf[:y2range] unless plotConf[:y2range].nil?
|
51
|
-
|
52
|
-
plot.xtics
|
53
|
-
plot.ytics
|
54
|
-
|
55
|
-
plot.xlabel plotConf[:xlabel]
|
56
|
-
plot.x2label plotConf[:x2label]
|
57
|
-
plot.ylabel plotConf[:ylabel]
|
58
|
-
plot.y2label plotConf[:y2label]
|
59
|
-
end
|
60
|
-
|
61
38
|
def UnifiedPlot.linePlot(inputs, plotConf: PLOT_DEFAULTS, title: '', oType: 'x11',oName: 'test')
|
62
39
|
# allow hash input
|
63
40
|
inputs = [inputs] if inputs.kind_of? Hash
|
64
41
|
|
42
|
+
plotConf = PLOT_DEFAULTS.merge(plotConf) unless plotConf == PLOT_DEFAULTS
|
43
|
+
|
65
44
|
Gnuplot.open do |gp|
|
66
45
|
Gnuplot::Plot.new( gp ) do |plot|
|
67
|
-
|
46
|
+
unless 'x11' == oType
|
47
|
+
plot.terminal "#{oType} size #{plotConf[:xsize]},#{plotConf[:ysize]} font #{plotConf[:font]} #{plotConf[:fontsize]}"
|
48
|
+
plot.output "#{oName}.#{oType}"
|
49
|
+
end
|
50
|
+
|
51
|
+
plot.title title
|
52
|
+
|
53
|
+
UnifiedPlot.applyConf(plot,plotConf)
|
54
|
+
|
55
|
+
plot.xtics
|
56
|
+
plot.ytics
|
68
57
|
|
69
58
|
inputs.each {|data|
|
70
59
|
data = DATA_DEFAULTS.merge(data)
|
@@ -80,20 +69,26 @@ module UnifiedPlot
|
|
80
69
|
plot.grid
|
81
70
|
end
|
82
71
|
end
|
72
|
+
return ('x11' != oType) ? [oName,oType].join('.') : nil
|
83
73
|
end
|
84
74
|
def UnifiedPlot.pm3d(inputs,plotConf: PLOT_DEFAULTS,title: '',oType: 'x11',oName: 'test')
|
85
|
-
# allow hash input
|
86
|
-
inputs = [inputs] if inputs.kind_of? Hash
|
87
|
-
|
88
|
-
# tempfile for holding the data (ugly, but works)
|
89
|
-
filename = `tempfile`.chomp
|
90
75
|
Gnuplot.open do |gp|
|
91
76
|
Gnuplot::SPlot.new( gp ) do |plot|
|
92
|
-
|
77
|
+
unless 'x11' == oType
|
78
|
+
plot.terminal oType
|
79
|
+
plot.output "#{oName}.#{oType}"
|
80
|
+
end
|
81
|
+
|
82
|
+
plotConf = PLOT_DEFAULTS.merge(plotConf)
|
83
|
+
plot.title title
|
84
|
+
|
85
|
+
UnifiedPlot.applyConf(plot,plotConf)
|
93
86
|
|
87
|
+
plot.xtics
|
88
|
+
plot.ytics
|
94
89
|
|
95
|
-
plot.nokey
|
96
90
|
# write stuff to a file
|
91
|
+
filename = `tempfile`.chomp
|
97
92
|
File.open(filename,'w') {|f|
|
98
93
|
inputs.each {|data|
|
99
94
|
f << data.join(' ')
|
@@ -103,12 +98,42 @@ module UnifiedPlot
|
|
103
98
|
|
104
99
|
plot.view "map"
|
105
100
|
plot.data << Gnuplot::DataSet.new("'"+filename+"'") do |ds|
|
106
|
-
ds.with
|
101
|
+
ds.with = "image"
|
107
102
|
ds.matrix = true
|
108
103
|
end
|
109
104
|
end
|
110
105
|
end
|
111
|
-
|
106
|
+
return ('x11' != oType) ? [oName,oType].join('.') : nil
|
107
|
+
end
|
108
|
+
def UnifiedPlot.heatMap(inputs,plotConf: PLOT_DEFAULTS,title: '',oType: 'x11',oName: 'test')
|
109
|
+
plotConf = PLOT_DEFAULTS.merge(plotConf)
|
110
|
+
Gnuplot.open do |gp|
|
111
|
+
Gnuplot::Plot.new( gp ) do |plot|
|
112
|
+
unless 'x11' == oType
|
113
|
+
plot.terminal oType
|
114
|
+
plot.output "#{oName}.#{oType}"
|
115
|
+
end
|
116
|
+
|
117
|
+
plot.title title
|
118
|
+
|
119
|
+
UnifiedPlot.applyConf(plot,plotConf)
|
120
|
+
|
121
|
+
plot.xtics
|
122
|
+
plot.ytics
|
123
|
+
|
124
|
+
inputs.each {|data|
|
125
|
+
data = DATA_DEFAULTS.merge(data)
|
126
|
+
dataset = [data[:x].to_a,data[:y].to_a,data[:z].to_a]
|
127
|
+
plot.data << Gnuplot::DataSet.new( dataset ) do |ds|
|
128
|
+
ds.with = 'image'
|
129
|
+
ds.axes = data[:axes]
|
130
|
+
ds.title = data[:title]
|
131
|
+
end
|
132
|
+
}
|
133
|
+
plot.grid
|
134
|
+
end
|
135
|
+
end
|
136
|
+
return ('x11' != oType) ? [oName,oType].join('.') : nil
|
112
137
|
end
|
113
138
|
def UnifiedPlot.fieldPlot(inputs)
|
114
139
|
RubyPython.start
|
@@ -116,4 +141,16 @@ module UnifiedPlot
|
|
116
141
|
pl.imshow(inputs.to_a.reverse)
|
117
142
|
pl.show()
|
118
143
|
end
|
144
|
+
private
|
145
|
+
def UnifiedPlot.applyConf(plot,config)
|
146
|
+
config.each {|k,v|
|
147
|
+
# avoid image settings
|
148
|
+
next if [:font,:fontsize,:xsize,:ysize,:label_position].include?(k)
|
149
|
+
unless [true,false].include?(v) then
|
150
|
+
plot.send(k,v)
|
151
|
+
else
|
152
|
+
plot.send(k)
|
153
|
+
end
|
154
|
+
}
|
155
|
+
end
|
119
156
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unifiedPlot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ralf Mueller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: single interface to line-plotting data in [],NArray and GSL::Vector format
|
14
14
|
email: stark.dreamdetective@gmail.com
|
@@ -38,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
38
|
version: '0'
|
39
39
|
requirements: []
|
40
40
|
rubyforge_project:
|
41
|
-
rubygems_version: 2.2.
|
41
|
+
rubygems_version: 2.2.2
|
42
42
|
signing_key:
|
43
43
|
specification_version: 4
|
44
44
|
summary: simple line plot for array-based inputs
|