unifiedPlot 0.0.1

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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/gemspec +23 -0
  3. data/lib/unifiedPlot.rb +71 -0
  4. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 380959e627743f7312dde624ee1e8f583e2042c0
4
+ data.tar.gz: 3fe3de255327767d25360b154487b1edbba391d2
5
+ SHA512:
6
+ metadata.gz: ddb218f74155933baa1ec91822dbf93161e8b4539539ef53533aff882690951af118d15f23847c42640b9323c2d72e56b81f7359176f816700fe9fe38e44f0bc
7
+ data.tar.gz: e706da5914bc7c42fb23fb658ec95f47f86b9a8e528fb03245d58d5526677747a7469fd5b4f3fa9d4885fd48fd1585bac8ebf592321df2f83aebcacd88c4bb5c
data/gemspec ADDED
@@ -0,0 +1,23 @@
1
+ require 'rubygems'
2
+
3
+ GEM_SPEC = Gem::Specification.new do |s|
4
+ s.name = "unifiedPlot"
5
+ s.version = '0.0.1'
6
+ s.date = Time.new.strftime("%Y-%m-%d")
7
+
8
+ s.description = 'single interface to line-plotting data in [],NArray and GSL::Vector format'
9
+ s.summary = 'simple line plot for array-based inputs'
10
+
11
+ s.platform = Gem::Platform::RUBY
12
+ s.files = ["lib/unifiedPlot.rb"] + ["gemspec"]
13
+ s.require_path = 'lib'
14
+
15
+ s.author = "Ralf Mueller"
16
+ s.email = "stark.dreamdetective@gmail.com"
17
+ s.homepage = "https://github.com/Try2Code/unifiedPlot"
18
+ s.licenses = ['BSD']
19
+
20
+ s.has_rdoc = false
21
+ end
22
+
23
+ # vim:ft=ruby
@@ -0,0 +1,71 @@
1
+ require 'gnuplot'
2
+
3
+ module UnifiedPlot
4
+
5
+ PLOT_DEFAULTS = {
6
+ :grid => true,
7
+ :ylabel => nil,
8
+ :y2label => nil,
9
+ :xlabel => nil,
10
+ :x2label => nil,
11
+ :label_position => 'bottom out',
12
+ }
13
+ DATA_DEFAULTS = {
14
+ :title => '',
15
+ :style => 'linespoints',
16
+ :axes => 'x1y1',
17
+ }
18
+ #
19
+ # input elements: data = {
20
+ # :y => [...], (required)
21
+ # :x => [...], (optional)
22
+ # :axes => 'x2y1', (optional)
23
+ # :title => '...',
24
+ # :style => 'lines',
25
+ # }
26
+ # plot = {
27
+ # :xlabel => '',
28
+ # :ylabel => '',
29
+ # :title => '',
30
+ # :grid => false.
31
+ # }
32
+ def UnifiedPlot.linePlot(inputs, plotConf: PLOT_DEFAULTS, title: '', oType: 'x11',oName: 'test')
33
+ Gnuplot.open do |gp|
34
+ Gnuplot::Plot.new( gp ) do |plot|
35
+ unless 'x11' == oType
36
+ plot.terminal oType
37
+ plot.output "#{oName}.#{oType}"
38
+ end
39
+
40
+ plotConf = PLOT_DEFAULTS.merge(plotConf)
41
+ plot.title title
42
+ plot.key plotConf[:label_position]
43
+
44
+ plot.xrange plotConf[:xrange] unless plotConf[:xrange].nil?
45
+ plot.x2range plotConf[:x2range] unless plotConf[:x2range].nil?
46
+ plot.yrange plotConf[:yrange] unless plotConf[:yrange].nil?
47
+ plot.y2range plotConf[:y2range] unless plotConf[:y2range].nil?
48
+
49
+ plot.xtics
50
+ plot.ytics
51
+
52
+ plot.xlabel plotConf[:xlabel]
53
+ plot.x2label plotConf[:x2label]
54
+ plot.ylabel plotConf[:ylabel]
55
+ plot.y2label plotConf[:y2label]
56
+ inputs.each {|data|
57
+ data = DATA_DEFAULTS.merge(data)
58
+ dataset = data.has_key?(:x) ? [data[:x].to_a,data[:y].to_a] : data[:y].to_a
59
+ plot.data << Gnuplot::DataSet.new( dataset ) do |ds|
60
+ ds.with = data[:style]
61
+ ds.axes = data[:axes]
62
+ plot.x2tics 'in' if data[:axes][0,2] == 'x2'
63
+ plot.y2tics 'in' if data[:axes][-2..-1] == 'y2'
64
+ ds.title = data[:title]
65
+ end
66
+ }
67
+ plot.grid
68
+ end
69
+ end
70
+ end
71
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unifiedPlot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ralf Mueller
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: single interface to line-plotting data in [],NArray and GSL::Vector format
14
+ email: stark.dreamdetective@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/unifiedPlot.rb
20
+ - gemspec
21
+ homepage: https://github.com/Try2Code/unifiedPlot
22
+ licenses:
23
+ - BSD
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.0.3
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: simple line plot for array-based inputs
45
+ test_files: []
46
+ has_rdoc: false