visualisation-utils 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.
- data/README.md +28 -0
- data/bin/scatter-plot +79 -0
- data/doc/gnuplot-gui.png +0 -0
- data/test-data/test-two-column.dat +6 -0
- data/test-data/test.dat +6 -0
- metadata +62 -0
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
visualisation-utils
|
2
|
+
===================
|
3
|
+
|
4
|
+
a collection of scripts for standard visualisation tasks
|
5
|
+
|
6
|
+
scatter-plot
|
7
|
+
============
|
8
|
+
|
9
|
+
Prints scatter plots of one or more columns of whitespace separated data using
|
10
|
+
gnuplot as a backend
|
11
|
+
|
12
|
+
|
13
|
+
~~~ .bash
|
14
|
+
cat | scatter-plot <<'END'
|
15
|
+
1 1
|
16
|
+
2 4
|
17
|
+
3 9
|
18
|
+
4 16
|
19
|
+
5 25
|
20
|
+
END
|
21
|
+
~~~
|
22
|
+
|
23
|
+
This incantation will bring up the gnuplot gui with the following graph:
|
24
|
+
|
25
|
+

|
26
|
+
|
27
|
+
|
28
|
+
|
data/bin/scatter-plot
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'trollop'
|
3
|
+
|
4
|
+
DATA_FILE_NAME="/tmp/plot-"+`date "+%s"`.strip+".dat"
|
5
|
+
PLOT_FILE_NAME="/tmp/plot-"+`date "+%s"`.strip+".plt"
|
6
|
+
|
7
|
+
|
8
|
+
@opts = Trollop::options do
|
9
|
+
banner "scatter-plot takes whitespace separated tables from stdin and renders them using gnuplot"
|
10
|
+
opt :outfile, "Output file name", :type => String, :short => 'o'
|
11
|
+
opt :legends, "Legend for columns, pipe separated list", :type => String, :short => 'l'
|
12
|
+
opt :numc, "Number of data columns", :type => Integer, :short => 'c'
|
13
|
+
opt :debug, "debug"
|
14
|
+
opt :title, "Title", :type=> String, :short => 't'
|
15
|
+
end
|
16
|
+
|
17
|
+
title = @opts[:title] || ""
|
18
|
+
|
19
|
+
# TODO I do want to be streamed!
|
20
|
+
input = `cat`
|
21
|
+
File.open(DATA_FILE_NAME, "w"){|f| f.write(input)}
|
22
|
+
|
23
|
+
numc_input=input.split(/\n/)[0].split(/\w*/).length - 1
|
24
|
+
|
25
|
+
numc = @opts[:numc] || numc_input
|
26
|
+
|
27
|
+
|
28
|
+
legends = (@opts[:legends] ? @opts[:legends].strip().split(/,/) : (1..(numc)).map{|x| ""}).map{|x| x.strip}
|
29
|
+
|
30
|
+
font = "Futura"
|
31
|
+
font_size = "12"
|
32
|
+
|
33
|
+
using_list = legends.zip(2..100).map{|text, index| "'#{DATA_FILE_NAME}' using 1:#{index} title \"#{text}\"" }.join(", ")
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
if (@opts[:outfile])
|
38
|
+
filename = @opts[:outfile]
|
39
|
+
extension = filename.gsub(/[^.]*\./,"")
|
40
|
+
if (extension == "png")
|
41
|
+
terminal=<<EOF
|
42
|
+
set term pngcairo font '#{font},#{font_size}' transparent size 1200,800
|
43
|
+
set output '#{filename}'
|
44
|
+
|
45
|
+
EOF
|
46
|
+
elsif (extension == "eps")
|
47
|
+
terminal=<<EOF
|
48
|
+
set term epscairo font '#{font},#{font_size}'
|
49
|
+
set output '#{filename}'
|
50
|
+
EOF
|
51
|
+
elsif (extension == "pdf")
|
52
|
+
terminal=<<EOF
|
53
|
+
set term pdfcairo font '#{font},#{font_size}'
|
54
|
+
set output '#{filename}'
|
55
|
+
EOF
|
56
|
+
else
|
57
|
+
throw "Unknown output format '.#{extension}'."
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
script = <<EOF
|
64
|
+
#{terminal}
|
65
|
+
set key top left
|
66
|
+
set title "#{title}"
|
67
|
+
plot #{using_list}
|
68
|
+
|
69
|
+
EOF
|
70
|
+
|
71
|
+
|
72
|
+
puts "data file " + DATA_FILE_NAME
|
73
|
+
puts "plot file " + PLOT_FILE_NAME
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
File.open(PLOT_FILE_NAME, "w"){|f| f.write(script)}
|
78
|
+
|
79
|
+
`gnuplot #{PLOT_FILE_NAME}`
|
data/doc/gnuplot-gui.png
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: visualisation-utils
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Felix Leipold
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-11 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: trollop
|
16
|
+
requirement: &2153124320 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2153124320
|
25
|
+
description: ! "visualisation-utils provides a number of utilities\n for
|
26
|
+
visualising data from the command line."
|
27
|
+
email: ''
|
28
|
+
executables:
|
29
|
+
- scatter-plot
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- README.md
|
34
|
+
- bin/scatter-plot
|
35
|
+
- doc/gnuplot-gui.png
|
36
|
+
- test-data/test-two-column.dat
|
37
|
+
- test-data/test.dat
|
38
|
+
homepage: https://github.com/programmiersportgruppe/visualisation-utils
|
39
|
+
licenses: []
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 1.8.15
|
59
|
+
signing_key:
|
60
|
+
specification_version: 3
|
61
|
+
summary: utilities for quick visualisation
|
62
|
+
test_files: []
|