unifiedPlot 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/gemspec +1 -1
  3. data/lib/unifiedPlot.rb +33 -81
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 871c40a719cbfb7f354b670da99f850abd42caad
4
- data.tar.gz: c71d375f4a014d2addf179b28690895e11c7ca4a
3
+ metadata.gz: 1e9d7f49741bbd243b7474f5995ae126c9f8e6d5
4
+ data.tar.gz: 47ba0e9b81999bcd464628907ca6e612ebae06a7
5
5
  SHA512:
6
- metadata.gz: d3f4b56a4cc0c0b1836866d516d6f1d63f92df881889254cdfe89fd346bdb43b56d79f69f759f9152f682b68aa125710e6c6b9f95ed0cfadcb8b01148fb1e4f3
7
- data.tar.gz: fdbb04ce285a46c10b70c16ead2fa96f0f18b6059084147d14410557abf2e9b5565c3ce85ca214e0e6235ac28ad29797f0c847a8f8c1f9b1eff1ea932f215161
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.2'
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
- 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
- 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
- unless 'x11' == oType
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 = "image"
106
+ ds.with = "image"
119
107
  ds.matrix = true
120
108
  end
121
109
  end
122
110
  end
123
- end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unifiedPlot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ralf Mueller