File: histograms.dem

package info (click to toggle)
gnuplot 6.0.2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 14,940 kB
  • sloc: ansic: 95,319; cpp: 7,590; makefile: 2,470; javascript: 2,328; sh: 1,531; lisp: 664; perl: 304; pascal: 191; tcl: 88; python: 46
file content (123 lines) | stat: -rw-r--r-- 3,687 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#
# Example of using histogram modes
#
reset
set title "US immigration from Europe by decade"
set datafile missing "-"
set xtics nomirror rotate by -45
set key noenhanced
#
# First plot using linespoints
set style data linespoints
plot 'immigration.dat' using 2:xtic(1) title columnheader(2), \
for [i=3:22] '' using i title columnheader(i)
#
pause -1 "<cr> to plot the same data as a histogram"
#
set title "US immigration from Northern Europe\nPlot selected data columns as histogram of clustered boxes"
set auto x
set yrange [0:300000]
set style data histogram
set style histogram cluster gap 1
set style fill solid border -1
set boxwidth 0.9
set xtic rotate by -45 scale 0
#set bmargin 10 
plot 'immigration.dat' using 6:xtic(1) ti col, '' u 12 ti col, '' u 13 ti col, '' u 14 ti col
#
pause -1 "<cr> to change the gap between clusters"
#
set title "US immigration from Northern Europe\n(same plot with larger gap between clusters)"
set style histogram gap 5
replot
#
pause -1 "<cr> to plot the same dataset as stacked histogram"
#
#
# Stacked histograms
#
set title "US immigration from Europe by decade\nPlot as stacked histogram"
set key invert reverse Left outside
set key autotitle columnheader
set yrange [0:7e6]
set auto x
unset xtics
set xtics nomirror rotate by -45 scale 0
set style data histogram
set style histogram rowstacked
set style fill solid border -1
set boxwidth 0.75
#
plot 'immigration.dat' using 2:xtic(1), for [i=3:22] '' using i
#
pause -1 "<cr> to rescale each stack to % of total"
#
# Stacked histograms by percent
#
set title "US immigration from Europe by decade\nFraction of total plotted as stacked histogram"
set key invert reverse Left outside
set yrange [0:100]
set ylabel "% of total"
unset ytics
set grid y
set border 3
set style data histograms
set style histogram rowstacked
set style fill solid border -1
set boxwidth 0.75
#
plot 'immigration.dat' using (100.*$2/$24):xtic(1) t column(2), \
     for [i=3:23] '' using (100.*column(i)/column(24)) title column(i) 
#
pause -1 "Now try histograms stacked by columns"
#
# Columnstacks
#	xtic labels should be picked up from column heads ('title column')
#	key titles should be picked up from row heads ('key(1)')
#
set title "Immigration from Northern Europe\n(columnstacked histogram)"
set style histogram columnstacked
set key noinvert box
set yrange [0:*]
set ylabel "Immigration by decade"
set xlabel "Country of Origin"
set tics scale 0.0
set ytics
unset xtics
set xtics norotate nomirror
plot 'immigration.dat' using 6 ti col, '' using 12 ti col, \
     '' using 13 ti col, '' using 14:key(1) ti col
#
pause -1 "Next we do several sets of parallel histograms"
#
# 'newhistogram' keyword to plot
#
set title "Immigration from different regions\n(give each histogram a separate title)"
set key under nobox
set style histogram clustered gap 1 title offset 2,0.25
set style fill solid noborder
set boxwidth 0.95
unset xtics
set xtics nomirror rotate by -45 scale 0 font ",8"
set xlabel "(note: histogram titles have specified offset relative to X-axis label)" offset 0,-2
set ytics font ",8"
set grid y
set auto y
plot \
newhistogram "Northern Europe", \
'immigration.dat' using "Sweden":xtic(1) t col, '' u "Denmark" t col, '' u "Norway" t col, \
newhistogram "Southern Europe", \
'' u "Greece":xtic(1) t col, '' u "Romania" t col, '' u "Yugoslavia" t col, \
newhistogram "British Isles", \
'' u "Ireland":xtic(1) t col, '' u "United_Kingdom" t col
#
pause -1 "Same plot using rowstacked histogram"
#
set style histogram rows
set boxwidth 0.8
set yrange [0:900000]
set xlabel "(Same plot using rowstacked rather than clustered histogram)"
replot
#
pause -1 "<cr> to finish histogram demo"
reset