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
|
#
# Illustrate use of concave hull to demarcate overlapping clusters
#
if (!strstrt(GPVAL_COMPILE_OPTIONS, "+CHI_SHAPES")) {
print "This copy of gnuplot does not support concave hulls"
exit # return to caller
}
set title "{/:Bold RA Fisher's iris data set}"
set title offset 0, -2
species(name) = strstrt(name,"setosa") ? 1 \
: strstrt(name,"versicolor") ? 2 \
: strstrt(name,"virginica") ? 3 \
: 0
set datafile separator comma
set datafile columnhead
set key title "Iris Species" font ":Bold"
set key outside top right offset screen -0.3, -.2
set key invert reverse Left
set border 3
set tics nomirror
set offset 0.5, 0.5, 0.5, 0.5
set xtics rangelimit
set ytics rangelimit
set xlabel "Sepal Width"
set ylabel "Petal Length"
set size square
plot 'iris.dat' using 2:3:(species(strcol(5))) with points lc variable notitle, \
keyentry with point pt 7 lc species("setosa") title "setosa", \
keyentry with point pt 7 lc species("versicolor") title "versicolor", \
keyentry with point pt 7 lc species("virginica") title "virginica"
pause -1 "<cr> to continue"
set title '{/:Bold Concave Hull chi\_length = 1.5 expand 0.1}'
set title offset 0, -2
set style fill transparent solid 0.3
chi_length = 1.5
plot for [s=1:3] \
'iris.dat' using (species(strcol(5)) == s ? $2 : NaN) : 3 \
concavehull smooth path expand 0.1 with polygon lc s notitle, \
\
'' using 2:3:(species(strcol(5))) with points pt 12 lc variable notitle, \
\
keyentry with ellipse lc species("setosa") title "setosa", \
keyentry with ellipse lc species("versicolor") title "versicolor", \
keyentry with ellipse lc species("virginica") title "virginica"
pause -1 "<cr> to continue"
reset
|