bplot 0.0.2.3 → 0.0.2.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.
- data/Roadmap +8 -0
- data/lib/bplot.rb +27 -11
- metadata +1 -1
data/Roadmap
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
== Version 0.0.3
|
4
4
|
|
5
|
+
* Add a "debug" mode "b = BPlot.new(:debug)" where we do not create a
|
6
|
+
Gnuplot instance and every command returns a text string. This makes
|
7
|
+
it possible to add a test suite for BPlot.
|
8
|
+
|
9
|
+
* Add a test suite. Use the Tutorial as an inspiration, but make it more
|
10
|
+
thorough and try to test only one feature at a time (though it is also
|
11
|
+
important to test every feature combination at least once).
|
12
|
+
|
5
13
|
* X and Y error bars.
|
6
14
|
|
7
15
|
* Variable, data-dependent point size.
|
data/lib/bplot.rb
CHANGED
@@ -53,7 +53,7 @@ class BPlot
|
|
53
53
|
#
|
54
54
|
# Every instance of BPlot has its own gnuplot process.
|
55
55
|
#
|
56
|
-
@pipe = IO.popen("gnuplot","w")
|
56
|
+
@pipe = IO.popen("gnuplot -p","w")
|
57
57
|
|
58
58
|
#
|
59
59
|
# Configure Gnuplot.
|
@@ -172,15 +172,19 @@ class BPlot
|
|
172
172
|
# method is currently in a state of flux and is for the moment undocumented.
|
173
173
|
def plot(*args)
|
174
174
|
|
175
|
-
|
175
|
+
all_data = []
|
176
176
|
all_plots = ''
|
177
177
|
while args.length > 0
|
178
178
|
#
|
179
179
|
# NEXT PLOT
|
180
180
|
#
|
181
|
-
#
|
182
|
-
|
183
|
-
|
181
|
+
# Anything that is of class Array or NMatrix is data.
|
182
|
+
this_data = []
|
183
|
+
while args[0].class == 'Array' or args[0].class == 'NMatrix'
|
184
|
+
this_data << args.shift
|
185
|
+
end
|
186
|
+
|
187
|
+
all_data << this_data
|
184
188
|
|
185
189
|
# - Get the settings for this plot.
|
186
190
|
# - If 'args' is not empty, there is another plot.
|
@@ -197,16 +201,28 @@ class BPlot
|
|
197
201
|
#
|
198
202
|
# Each plot needs a separate stream of data separated by 'e' ("end").
|
199
203
|
#
|
200
|
-
|
204
|
+
nblocks = all_data.length
|
201
205
|
|
202
|
-
stream = (1..
|
203
|
-
x = data.shift
|
204
|
-
y = data.shift
|
205
|
-
n = x.is_a?(Array) ? x.length - 1 : x.shape[0] - 1
|
206
|
+
stream = (1..nblocks).map { |s|
|
206
207
|
|
207
|
-
|
208
|
+
ncols = all_data[s].length
|
209
|
+
nrows = all_data[s][0].class == 'Array' ? all_data[s][0].length
|
210
|
+
: all_data[s][0].shape[0] - 1
|
211
|
+
|
212
|
+
(0..nrows).map { |r|
|
213
|
+
(0..ncols).map { |c| " " + all_data[s][c][r]
|
214
|
+
}.join + "\n"
|
215
|
+
}.join + "e\n"
|
208
216
|
}.join
|
209
217
|
|
218
|
+
# stream = (1..nstreams).map { |s|
|
219
|
+
# x = data.shift
|
220
|
+
# y = data.shift
|
221
|
+
# n = x.is_a?(Array) ? x.length - 1 : x.shape[0] - 1
|
222
|
+
#
|
223
|
+
# (0..n).map { |i| "#{x[i]} #{y[i]}\n" }.join + "e\n"
|
224
|
+
# }.join
|
225
|
+
|
210
226
|
@pipe.puts "plot #{all_plots} \n#{stream}"
|
211
227
|
end
|
212
228
|
|