POLYGON command
Syntax: |
POLYGON xpoly ypoly xdata ydata key
|
Qualifiers: |
\INSIDE, \OUTSIDE
|
Defaults: |
\INSIDE
|
The POLYGON
command creates a vector, key
, which will have the same
length as the input vectors, xdata
and ydata
. By default,
key[i] = 1
if the point (xdata[i],ydata[i])
is inside
the polygon defined by input vectors xpoly
and ypoly
, otherwise
key[i] = 0
. If the \OUTSIDE
qualifier is used,
key[i] = 0
if the point (xdata[i],ydata[i])
is inside the polygon, otherwise key[i] = 1
.
Example
GENERATE\RANDOM X -5 5 2000 ! generate some "data"
GENERATE\RANDOM Y 10 20 2000 !
WINDOW 5 !
SET PLOTSYMBOL -11 ! choose unjoined point plotting symbol
GRAPH X Y ! display the data graphically
XP = {-0.5;1.2;-0.2;1.3;-3;-2} ! the polygon vertices
YP = {13;13.5;16;18.5;18;14} !
POLYGON\OUTSIDE XP YP X Y K !! find data points outside polygon, create key vector, K
WINDOW 7 !
SET PLOTSYMBOL -11 ! choose unjoined point plotting symbol
IDX = WHERE(K=1) ! choose indices of points outside polygon
GRAPH X[IDX] Y[IDX] ! display data without unwanted points
SET PLOTSYMBOL 0 ! choose no plotting symbol
GRAPH\OVERLAY XP//{-0.5} YP//{13} ! overlay the polygon (close by appending first point)