unifiedPlot 0.0.2 → 0.0.3
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 +33 -81
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e9d7f49741bbd243b7474f5995ae126c9f8e6d5
|
4
|
+
data.tar.gz: 47ba0e9b81999bcd464628907ca6e612ebae06a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67d63b5d812c4a427bd1ee7a5533904662630a7e905892c9d7a716c11473d34519a868e07e4e9a62aaf83dfb95162e58fc3525108e9476f19009f098d601f1b2
|
7
|
+
data.tar.gz: 172539447d007e9ebb700d4a6a5d139d85ce4c4e6b30114ee93cee05c4a9fadc0d7ee11f593738b758d96fc1f598ced5692ce25e033a6f9f839f2b180df3f09a
|
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.3'
|
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
@@ -35,35 +35,37 @@ 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
|
+
|
38
61
|
def UnifiedPlot.linePlot(inputs, plotConf: PLOT_DEFAULTS, title: '', oType: 'x11',oName: 'test')
|
39
62
|
# allow hash input
|
40
63
|
inputs = [inputs] if inputs.kind_of? Hash
|
41
64
|
|
42
|
-
plotConf = PLOT_DEFAULTS.merge(plotConf) unless plotConf == PLOT_DEFAULTS
|
43
|
-
|
44
65
|
Gnuplot.open do |gp|
|
45
66
|
Gnuplot::Plot.new( gp ) do |plot|
|
46
|
-
|
47
|
-
plot.terminal "#{oType} size #{plotConf[:xsize]},#{plotConf[:ysize]} font #{plotConf[:font]} #{plotConf[:fontsize]}"
|
48
|
-
plot.output "#{oName}.#{oType}"
|
49
|
-
end
|
50
|
-
|
51
|
-
plotConf = PLOT_DEFAULTS.merge(plotConf)
|
52
|
-
plot.title title
|
53
|
-
plot.key plotConf[:label_position]
|
67
|
+
setPlotDefaults(plot,plotConf,title,oType,oName)
|
54
68
|
|
55
|
-
plot.xrange plotConf[:xrange] unless plotConf[:xrange].nil?
|
56
|
-
plot.x2range plotConf[:x2range] unless plotConf[:x2range].nil?
|
57
|
-
plot.yrange plotConf[:yrange] unless plotConf[:yrange].nil?
|
58
|
-
plot.y2range plotConf[:y2range] unless plotConf[:y2range].nil?
|
59
|
-
|
60
|
-
plot.xtics
|
61
|
-
plot.ytics
|
62
|
-
|
63
|
-
plot.xlabel plotConf[:xlabel]
|
64
|
-
plot.x2label plotConf[:x2label]
|
65
|
-
plot.ylabel plotConf[:ylabel]
|
66
|
-
plot.y2label plotConf[:y2label]
|
67
69
|
inputs.each {|data|
|
68
70
|
data = DATA_DEFAULTS.merge(data)
|
69
71
|
dataset = data.has_key?(:x) ? [data[:x].to_a,data[:y].to_a] : data[:y].to_a
|
@@ -80,32 +82,18 @@ module UnifiedPlot
|
|
80
82
|
end
|
81
83
|
end
|
82
84
|
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
|
83
90
|
Gnuplot.open do |gp|
|
84
91
|
Gnuplot::SPlot.new( gp ) do |plot|
|
85
|
-
|
86
|
-
plot.terminal oType
|
87
|
-
plot.output "#{oName}.#{oType}"
|
88
|
-
end
|
89
|
-
|
90
|
-
plotConf = PLOT_DEFAULTS.merge(plotConf)
|
91
|
-
plot.title title
|
92
|
-
plot.key plotConf[:label_position]
|
93
|
-
|
94
|
-
plot.xrange plotConf[:xrange] unless plotConf[:xrange].nil?
|
95
|
-
plot.x2range plotConf[:x2range] unless plotConf[:x2range].nil?
|
96
|
-
plot.yrange plotConf[:yrange] unless plotConf[:yrange].nil?
|
97
|
-
plot.y2range plotConf[:y2range] unless plotConf[:y2range].nil?
|
98
|
-
|
99
|
-
plot.xtics
|
100
|
-
plot.ytics
|
92
|
+
setPlotDefaults(plot,plotConf,title,oType,oName)
|
101
93
|
|
102
|
-
plot.xlabel plotConf[:xlabel]
|
103
|
-
plot.x2label plotConf[:x2label]
|
104
|
-
plot.ylabel plotConf[:ylabel]
|
105
|
-
plot.y2label plotConf[:y2label]
|
106
94
|
|
95
|
+
plot.nokey
|
107
96
|
# write stuff to a file
|
108
|
-
filename = `tempfile`.chomp
|
109
97
|
File.open(filename,'w') {|f|
|
110
98
|
inputs.each {|data|
|
111
99
|
f << data.join(' ')
|
@@ -115,48 +103,12 @@ module UnifiedPlot
|
|
115
103
|
|
116
104
|
plot.view "map"
|
117
105
|
plot.data << Gnuplot::DataSet.new("'"+filename+"'") do |ds|
|
118
|
-
ds.with
|
106
|
+
ds.with = "image"
|
119
107
|
ds.matrix = true
|
120
108
|
end
|
121
109
|
end
|
122
110
|
end
|
123
|
-
|
124
|
-
def UnifiedPlot.heatMap(inputs,plotConf: PLOT_DEFAULTS,title: '',oType: 'x11',oName: 'test')
|
125
|
-
Gnuplot.open do |gp|
|
126
|
-
Gnuplot::Plot.new( gp ) do |plot|
|
127
|
-
unless 'x11' == oType
|
128
|
-
plot.terminal oType
|
129
|
-
plot.output "#{oName}.#{oType}"
|
130
|
-
end
|
131
|
-
|
132
|
-
plotConf = PLOT_DEFAULTS.merge(plotConf)
|
133
|
-
plot.title title
|
134
|
-
plot.key plotConf[:label_position]
|
135
|
-
|
136
|
-
plot.xrange plotConf[:xrange] unless plotConf[:xrange].nil?
|
137
|
-
plot.x2range plotConf[:x2range] unless plotConf[:x2range].nil?
|
138
|
-
plot.yrange plotConf[:yrange] unless plotConf[:yrange].nil?
|
139
|
-
plot.y2range plotConf[:y2range] unless plotConf[:y2range].nil?
|
140
|
-
|
141
|
-
plot.xtics
|
142
|
-
plot.ytics
|
143
|
-
|
144
|
-
plot.xlabel plotConf[:xlabel]
|
145
|
-
plot.x2label plotConf[:x2label]
|
146
|
-
plot.ylabel plotConf[:ylabel]
|
147
|
-
plot.y2label plotConf[:y2label]
|
148
|
-
inputs.each {|data|
|
149
|
-
data = DATA_DEFAULTS.merge(data)
|
150
|
-
dataset = [data[:x].to_a,data[:y].to_a,data[:z].to_a]
|
151
|
-
plot.data << Gnuplot::DataSet.new( dataset ) do |ds|
|
152
|
-
ds.with = 'image'
|
153
|
-
ds.axes = data[:axes]
|
154
|
-
ds.title = data[:title]
|
155
|
-
end
|
156
|
-
}
|
157
|
-
plot.grid
|
158
|
-
end
|
159
|
-
end
|
111
|
+
FileUtils.rm(filename)
|
160
112
|
end
|
161
113
|
def UnifiedPlot.fieldPlot(inputs)
|
162
114
|
RubyPython.start
|