visualisation-utils 0.1 → 0.2
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 +19 -1
- data/Rakefile +5 -0
- data/bin/overlay +16 -0
- data/bin/scatter-plot +56 -7
- data/visualisation-utils.gemspec +23 -0
- metadata +14 -5
data/README.md
CHANGED
@@ -3,6 +3,13 @@ visualisation-utils
|
|
3
3
|
|
4
4
|
a collection of scripts for standard visualisation tasks
|
5
5
|
|
6
|
+
Installing
|
7
|
+
==========
|
8
|
+
|
9
|
+
~~~ .bash
|
10
|
+
gem install visualisation-utils
|
11
|
+
~~~
|
12
|
+
|
6
13
|
scatter-plot
|
7
14
|
============
|
8
15
|
|
@@ -24,5 +31,16 @@ This incantation will bring up the gnuplot gui with the following graph:
|
|
24
31
|
|
25
32
|

|
26
33
|
|
27
|
-
|
34
|
+
TODO
|
35
|
+
====
|
36
|
+
|
37
|
+
* Overriding of autoscale
|
38
|
+
* Create nice PNGs
|
39
|
+
* Line plots
|
40
|
+
* Changing changing the size of the dots
|
41
|
+
* Secondary y-axis
|
42
|
+
* Bar chart single series
|
43
|
+
* Bar chart multiple series
|
44
|
+
* Discrete y-values, e.g. to visualise events over time
|
45
|
+
* Histogram plotting
|
28
46
|
|
data/Rakefile
ADDED
data/bin/overlay
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#/usr/bin/env bash
|
2
|
+
|
3
|
+
# Overlaying to pictures and adding white background
|
4
|
+
|
5
|
+
FOREGROUND=$1
|
6
|
+
BACKGROUND=$2
|
7
|
+
set -e
|
8
|
+
set -u
|
9
|
+
|
10
|
+
basename="$(basename "$FOREGROUND")"
|
11
|
+
SIGNED=`dirname "$FOREGROUND"`"/${basename%.*}.branded.png"
|
12
|
+
|
13
|
+
convert "${FOREGROUND}" "${BACKGROUND}" -gravity center -compose DstOver -composite -background white -format png /tmp/output.png
|
14
|
+
convert /tmp/output.png -background white -flatten -format png "$SIGNED"
|
15
|
+
|
16
|
+
|
data/bin/scatter-plot
CHANGED
@@ -9,9 +9,16 @@ PLOT_FILE_NAME="/tmp/plot-"+`date "+%s"`.strip+".plt"
|
|
9
9
|
banner "scatter-plot takes whitespace separated tables from stdin and renders them using gnuplot"
|
10
10
|
opt :outfile, "Output file name", :type => String, :short => 'o'
|
11
11
|
opt :legends, "Legend for columns, pipe separated list", :type => String, :short => 'l'
|
12
|
+
opt :plot_styles, "Style of plot, comma separated list, values as expected by gnuplot, e.g. lines, points, linespoints, defaults to points", :type => String
|
13
|
+
opt :axis_labels, "Labels for axes, pipe separated list", :type => String
|
14
|
+
opt :axes, "Axes used for the respective columns, e.g. (1|possible value are ", :type => String
|
12
15
|
opt :numc, "Number of data columns", :type => Integer, :short => 'c'
|
13
16
|
opt :debug, "debug"
|
14
17
|
opt :title, "Title", :type=> String, :short => 't'
|
18
|
+
opt :font, "Font", :type => String, :short => 'f'
|
19
|
+
opt :time, "Time format for time series data, strftime expression", :type => String
|
20
|
+
opt :ranges, "A list comma separated pairs of gnuplot range-expressions, e.g. xrange [-10:10], yrange[0:40], y2range [0:1]", type:String
|
21
|
+
opt :extra_header, "Extra commands to be put in the header of the gnuplot file", :type => String
|
15
22
|
end
|
16
23
|
|
17
24
|
title = @opts[:title] || ""
|
@@ -20,19 +27,27 @@ title = @opts[:title] || ""
|
|
20
27
|
input = `cat`
|
21
28
|
File.open(DATA_FILE_NAME, "w"){|f| f.write(input)}
|
22
29
|
|
23
|
-
numc_input=input.split(/\n/)[0].split(/\
|
30
|
+
numc_input=input.split(/\n/)[0].split(/\s+/).length - 1
|
31
|
+
puts "Detected numc y-columns #{numc_input}"
|
32
|
+
|
24
33
|
|
25
34
|
numc = @opts[:numc] || numc_input
|
26
35
|
|
36
|
+
axis_labels = (@opts[:axis_labels] || " | ").split("|")
|
27
37
|
|
28
38
|
legends = (@opts[:legends] ? @opts[:legends].strip().split(/,/) : (1..(numc)).map{|x| ""}).map{|x| x.strip}
|
29
39
|
|
30
|
-
|
31
|
-
|
40
|
+
axes = @opts[:axes] ? @opts[:axes].split("|") : [1] * legends.length
|
41
|
+
|
42
|
+
plot_styles = @opts[:plot_styles] ? @opts[:plot_styles].strip().split(/,/) : [ "points" ] * legends.length
|
32
43
|
|
33
|
-
|
44
|
+
ranges = @opts[:ranges] ? @opts[:ranges].split(",").map{ |r| "set #{r}"}.join("\n") : ""
|
34
45
|
|
46
|
+
font = @opts[:font] || "Futura"
|
47
|
+
font_size = "12"
|
48
|
+
using_list = legends.zip((2..100).to_a, axes, plot_styles).map{|text, index, yaxis, plot_style| "'#{DATA_FILE_NAME}' using 1:#{index} title \"#{text}\" with #{plot_style} ps 2.0 lw 2.0 axes x1y#{yaxis}"}.join(", ")
|
35
49
|
|
50
|
+
extra_header = @opts[:extra_header] || ""
|
36
51
|
|
37
52
|
if (@opts[:outfile])
|
38
53
|
filename = @opts[:outfile]
|
@@ -45,12 +60,17 @@ if (@opts[:outfile])
|
|
45
60
|
EOF
|
46
61
|
elsif (extension == "eps")
|
47
62
|
terminal=<<EOF
|
48
|
-
set term epscairo font '#{font},#{font_size}'
|
63
|
+
set term epscairo size 1200,800 font '#{font},#{font_size}'
|
49
64
|
set output '#{filename}'
|
50
65
|
EOF
|
51
66
|
elsif (extension == "pdf")
|
52
67
|
terminal=<<EOF
|
53
|
-
set term pdfcairo font '#{font},#{font_size}'
|
68
|
+
set term pdfcairo size 22cm,14cm font '#{font},#{font_size}'
|
69
|
+
set output '#{filename}'
|
70
|
+
EOF
|
71
|
+
elsif (extension == "svg")
|
72
|
+
terminal=<<EOF
|
73
|
+
set term svg size 1200,800 font '#{font},#{font_size}'
|
54
74
|
set output '#{filename}'
|
55
75
|
EOF
|
56
76
|
else
|
@@ -60,10 +80,39 @@ EOF
|
|
60
80
|
|
61
81
|
end
|
62
82
|
|
83
|
+
if (@opts[:time])
|
84
|
+
timeExpr=@opts[:time]
|
85
|
+
time=<<EOF
|
86
|
+
set xdata time
|
87
|
+
set timefmt "#{timeExpr}"
|
88
|
+
set format x "%H:%M"
|
89
|
+
set autoscale x
|
90
|
+
EOF
|
91
|
+
else
|
92
|
+
time=""
|
93
|
+
end
|
94
|
+
|
95
|
+
|
63
96
|
script = <<EOF
|
64
97
|
#{terminal}
|
65
|
-
set
|
98
|
+
#{axis_labels.map{ | axis | pair=axis.split(":"); "set #{pair[0]}label '#{pair[1]}';"}.join("\n")}
|
99
|
+
set key outside
|
100
|
+
set key left top
|
101
|
+
#set offsets 1, 1, 1, 0
|
102
|
+
set style line 1 lc rgb '#8b1a0e' pt 1 ps 1 lt 1 lw 2 # --- red
|
103
|
+
set style line 2 lc rgb '#5e9c36' pt 6 ps 1 lt 1 lw 2 # --- green
|
104
|
+
set style line 11 lc rgb '#808080' lt 1
|
105
|
+
set border 3 back ls 11
|
106
|
+
set tics nomirror
|
107
|
+
set style line 12 lc rgb '#808080' lt 0 lw 1
|
108
|
+
set grid back ls 12
|
109
|
+
set y2tics
|
110
|
+
#{extra_header}
|
111
|
+
|
112
|
+
#{ranges}
|
113
|
+
|
66
114
|
set title "#{title}"
|
115
|
+
#{time}
|
67
116
|
plot #{using_list}
|
68
117
|
|
69
118
|
EOF
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'visualisation-utils'
|
3
|
+
s.summary = 'utilities for quick visualisation'
|
4
|
+
s.description = 'visualisation-utils provides a number of utilities
|
5
|
+
for visualising data from the command line.'
|
6
|
+
s.version = '0.2'
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
|
9
|
+
s.files = ['bin/scatter-plot']
|
10
|
+
|
11
|
+
s.bindir = 'bin'
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
|
+
|
16
|
+
s.author = 'Felix Leipold'
|
17
|
+
s.email = ''
|
18
|
+
s.homepage = 'https://github.com/programmiersportgruppe/visualisation-utils'
|
19
|
+
|
20
|
+
|
21
|
+
s.add_dependency('trollop')
|
22
|
+
end
|
23
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: visualisation-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-07-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: trollop
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,20 +21,29 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
description: ! "visualisation-utils provides a number of utilities\n for
|
26
31
|
visualising data from the command line."
|
27
32
|
email: ''
|
28
33
|
executables:
|
34
|
+
- overlay
|
29
35
|
- scatter-plot
|
30
36
|
extensions: []
|
31
37
|
extra_rdoc_files: []
|
32
38
|
files:
|
33
39
|
- README.md
|
40
|
+
- Rakefile
|
41
|
+
- bin/overlay
|
34
42
|
- bin/scatter-plot
|
35
43
|
- doc/gnuplot-gui.png
|
36
44
|
- test-data/test-two-column.dat
|
37
45
|
- test-data/test.dat
|
46
|
+
- visualisation-utils.gemspec
|
38
47
|
homepage: https://github.com/programmiersportgruppe/visualisation-utils
|
39
48
|
licenses: []
|
40
49
|
post_install_message:
|
@@ -55,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
64
|
version: '0'
|
56
65
|
requirements: []
|
57
66
|
rubyforge_project:
|
58
|
-
rubygems_version: 1.8.
|
67
|
+
rubygems_version: 1.8.24
|
59
68
|
signing_key:
|
60
69
|
specification_version: 3
|
61
70
|
summary: utilities for quick visualisation
|