File: heatmaps.dem

package info (click to toggle)
gnuplot 5.4.1%2Bdfsg1-1%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,316 kB
  • sloc: ansic: 85,877; cpp: 7,440; makefile: 2,548; javascript: 2,322; sh: 1,542; lisp: 667; perl: 304; pascal: 191; tcl: 88; python: 46
file content (156 lines) | stat: -rw-r--r-- 3,401 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#
# Various ways to create a 2D heat map from ascii data
#

set title "Heat Map generated from a file containing Z values only"
unset key
set tic scale 0

# Color runs from white to green
set palette rgbformula -7,2,-7
set cbrange [0:5]
set cblabel "Score"
unset cbtics

set xrange [-0.5:4.5]
set yrange [-0.5:4.5]

$map1 << EOD
5 4 3 1 0
2 2 0 0 1
0 0 0 1 0
0 0 0 2 3
0 1 2 4 3
EOD

set view map
splot '$map1' matrix with image

pause -1 "Hit return to continue"

set title "Heat Map generated by 'plot' from a stream of XYZ values"\
         ."\nNB: Rows must be separated by blank lines!"

$map2 << EOD
0 0 5
0 1 4
0 2 3
0 3 1
0 4 0

1 0 2
1 1 2
1 2 0
1 3 0
1 4 1

2 0 0
2 1 0
2 2 0
2 3 1
2 4 0

3 0 0
3 1 0
3 2 0
3 3 2
3 4 3

4 0 0
4 1 1
4 2 2
4 3 4
4 4 3
EOD 

plot '$map2' using 2:1:3 with image

pause -1 "Hit return to continue"

set title "Heat map with non-zero pixel values written as labels"
plot $map1 matrix using 1:2:3 with image, \
     $map1 matrix using 1:2:($3 == 0 ? "" : sprintf("%g",$3) ) with labels

pause -1 "Hit return to continue"

set title "Heat map from csv data with column and row labels"

$map3 << EOD
,Apple,Bacon,Cream,Donut,Eclair
Row 1, 5, 4, 3, 1, 0
Row 2, 2, 2, 0, 0, 1
Row 3, 0, 0, 0, 1, 0
Row 4, 0, 0, 0, 2, 3
Row 5, 0, 1, 2, 4, 3
EOD

set datafile separator comma
plot '$map3' matrix rowheaders columnheaders using 1:2:3 with image
set datafile separator

pause -1

# Some output modes (SVG, HTML5) allow smoothing of adjacent pixels,
# which may not be desired. This is not normally an issue with PNG or PDF.
# The `pixels` option forces pixel-by-pixel drawing with no smoothing.

unset colorbox
set format xy ""
set multiplot layout 1,2 title "Compare 'image' and 'image pixels' modes" \
    margin screen 0.05, 0.95, 0.10, 0.85 spacing screen 0.05
set title "plot with image"
plot $map1 matrix using 1:2:3 with image
set title "plot with image pixels"
plot $map1 matrix using 1:2:3 with image pixels
unset multiplot

pause -1 "Hit return to continue"

reset

#
# Demonstrate use of 4th data column to color a 3D surface.
# Also demonstrate use of the pseudodata special file '++'.
# This plot is nice for exploring the effect of the 'l' and 'L' hotkeys.
#
set view 49, 28, 1, 1.48
set urange [ 5 : 35 ] noreverse nowriteback
set vrange [ 5 : 35 ] noreverse nowriteback
# set zrange [ 1.0 : 3.0 ] noreverse nowriteback
set ticslevel 0
set format cb "%4.1f"
set colorbox user size .03, .6 noborder
set cbtics scale 0

set samples 25, 25
set isosamples 50, 50

set title "4D data (3D Heat Map)"\
          ."\nIndependent value color-mapped onto 3D surface"  offset 0,1
set xlabel "x" offset 3, 0, 0 
set ylabel "y" offset -5, 0, 0
set zlabel "z" offset 2, 0, 0 
set pm3d implicit at s

Z(x,y) = 100. * (sinc(x,y) + 1.5)
sinc(x,y) = sin(sqrt((x-20.)**2+(y-20.)**2))/sqrt((x-20.)**2+(y-20.)**2)
color(x,y) = 10. * (1.1 + sin((x-20.)/5.)*cos((y-20.)/10.))

splot '++' using 1:2:(Z($1,$2)):(color($1,$2)) with pm3d title "4 data columns x/y/z/color"

pause -1 "Hit return to continue"

set title "4D data (3D Heat Map)"\
          ."\nZ is contoured. Independent value is color-mapped"  offset 0,1

set view map
set ylabel norotate offset -1,0

set contour base
splot '++' using 1:2:(Z($1,$2)):(color($1,$2)) with pm3d title "4 data columns x/y/z/color"

pause -1 "Hit return to continue"

# Release datablocks used in this demo
undefine $map1 $map2 $map3
reset