-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot2.gp
174 lines (106 loc) · 4.11 KB
/
plot2.gp
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
157
158
159
160
161
162
163
164
165
166
167
168
# save as a plot2.gp
# run : gnuplot plot2.gp
set palette model HSV functions gray,1,1
set cbrange [0:1]
# Set the output file type
set terminal png
# list of gradient names; update it maually
# gnuplot array is numbered from 1 to words(array), not like c arrays
# update list with order as in function GiveColor from p.c
titles = "Rainbow Linas Magma GrayL GrayNL2 GrayNL3 GraySqrt Green NewLinas CoolWarm GrayGamma GrayNL3Wave2 GrayNL3Wave10 GraySqrtWave ColorLWave ColorLWaveInverted NL3Wave5NonInv"
spaces = "RGB HSV"
# length of array spaces = nMax, but tex files are numbered from 0 to nMax-1 ( c style)
nMax = words(spaces)
# legend
set key inside bottom center horizontal
set key horizontal
set key font ",8"
# remove upper and right axis
set border 3 back
set xtics nomirror out
set ytics nomirror
set xlabel "gradient position"
set ylabel " intensity"
# adjust y range to make a space for the legend
set yrange [-0.2:1.1]
n=0
# Set the output file name
outfile = sprintf('%d.png',n)
set output outfile
# Set the intput file name
infile = sprintf('%d.txt',0)
# title of the image for the array of strings
sTitle = sprintf(" %s profiles of the rainbow colormap", word(spaces,n) )
set title sTitle
# Now plot the data with lines and points
plot infile using 1:2 with lines linecolor rgb 'red' title 'R', \
'' using 1:3 w lines linecolor rgb 'green' title 'G', \
'' using 1:4 w lines linecolor rgb 'blue' title 'B',\
'' using 1:5 w lines linecolor rgb 'black' title 'Y'
# Set the output file name
outfile = sprintf('%d_hsv.png',n)
set output outfile
# Set the intput file name
infile = sprintf('%d.txt',0)
# title of the image for the array of strings
sTitle = sprintf(" %s profiles of the rainbow colormap", word(spaces,n) )
set title sTitle
# Now plot the data with lines and points
plot infile using 1:6 with lines linecolor rgb 'red' title 'H', \
'' using 1:7 w lines linecolor rgb 'green' title 'S', \
'' using 1:8 w lines linecolor rgb 'blue' title 'V'
# 3d plot of rgb profile
set xlabel "R"
set ylabel "G"
set zlabel "B"
unset yrange
set nokey
unset tics
set xrange [0.0:1.0]
set yrange [0.0:1.0]
set zrange [0.0:1.0]
set grid
set border 4095 ls 1 lc rgb "black" # Draw a complete box around a `splot`:
set xzeroaxis
set yzeroaxis
# set view <rot_x>{,{<rot_z>}{,{<scale>}{,<scale_z>}}}
# view is 60 rot_x, 30 rot_z, 1 scale, 1 scale_z
set view 60,75
set view equal xyz # to get an orthographic projection with all of the axes scaled equally
set xyplane at 0 # adjusts the position at which the xy plane is drawn in a 3D plot
# Set the output file name
outfile = sprintf('%d_3d_60_75_v.png',n)
set output outfile
# title of the image for the array of strings
sTitle = sprintf("3D %s profile of the rainbow colormap", word(spaces,n+1) )
set title sTitle
# http://www.bersch.net/gnuplot-doc/linetypes,-colors,-and-styles.html
# There are several ways to specify color when one plots using gnuplot.
# Among them hex-string (like "#0000ff") and rgbvalue (like "256")
# specification is very important.
# here rgb value is computed
rgb(r,g,b) = 65536*int(255*r) + 256*int(255*g) + int(255*b)
# http://gnuplot-surprising.blogspot.com/2012/10/
#convert dec color value to its hex string
dec2hex(dec)=gprintf("%02x",dec)
#convert rgb color value to its hex string
rgb2hex(r,g,b)="#".\
dec2hex(255*r).\
dec2hex(255*g).\
dec2hex(255*b)
# Now plot the data with lines and points
set label "(0,0,0)" at -0.1,0,0 right
#set label "0" at 1,-0.1,0 right
#set label "1" at 1,+1.1,0 right
#set label "2" at 0,1.1,0 right
#set label "3" at 0,1,1 left
#set label "4" at 0,0,1 left
# set label "5" at 1,0,1 left
#set label "6" at 1,0,0 left
set label "(1,1,1)" at 1.1,1,1 left
splot infile using 1:1:1 with lines lw 3 lc rgb 'gray',\
infile using 2:3:4:(rgb($2,$3,$4)) with points pt 7 ps 2 lc rgb variable ,\
'-' w p pt 7 ps 2 lc rgb 'black'
0 0 0
1 1 1
e