Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: plot
See also: setmaskp setmaskl grsurface setmaskt createcolor freecolor

Quantlet: setmask
Description: front-end for the setting of mask vectors that allows easy definitions for points, lines (polygons), surfaces and text.

Link:
Usage: xm = setmask(x{,s1{,s2,...}})
Input:
x n x k matrix, representing some data. For a curve (2-dimensional), data should be n x 2, and (typically) be sorted by the first column. For a surface (3-dimensional), data should be n x 3, sorted by the first column and the first two columns should form a grid.
s1,s2,... scalar, vector or matrix, string or numeric. Arguments of parameters may be a keyword or an attribute,used like setmask{x{,keyword1{,attribute1{,attribute2...{,keyword2{attribute1{,attribute2,...{,...}}}}}}}} The keywords are used to separate different graphical objects (points, line, surface, text) from each other: Main keywords specify the graphical object: "points": draws points "line": draws a line "surface": draws a surface "text": writes text "reset": special keyword, see the note below If no keyword is specified, points are assumed as graphical objects Attributes Attributes refer to the object defined by the preceding keyword. Attributes without preceding keyword are assigned to points. Subkeywords are predefined string attributes assigned to each graphical object: subkeywords for points color = "black", "blue", "green", "cyan", "red", "magenta", "yellow", "white" size = "nopoint", "tiny", "small", "medium", "large", "huge" (corresponding to values 0, 1, 2, 4, 8, 12, 15 in setmaskp) style = "empty", "point", "rectangle", "circle", "triangle", "xsymbol" "rhomb", "fillrectangle", "fillcircle", "fillrhomb", "filltriangle", "cross", "star", "grid", "gridrhomb" (defaults = "black", "medium", "circle") subkeywords for lines color = "black", "blue", "green", "cyan", "red", "magenta", "yellow", "white" size = "noline", "thin", "medium", "thick", "band", "fill" (corresponding to values 0, 1, 2, 5, 14, 15 in setmaskl) style = "invisible", "solid", "dashed", "dotted" (defaults = "black", "medium", "solid") A polygon is optional, the default polygon for "line" is (1:n)' which connects points subsequently. An optional polygon definition must immediately follow the "line" keyword. subkeywords for text color = "black", "blue", "green", "cyan", "red", "magenta", "yellow", "white" size = "tiny", "small", "medium", "large", "huge" (corresponding to font sizes 8, 12, 14, 16, 20 in setmaskt) style = "request", "center", "right", "below", "left", "above" (defaults = "black", "medium", "center") Text to be displayed must immediately follow the "text" keyword. Numerical attributes need to follow the rules of setmaskp, setmaskl and setmaskt (e.g., 0..7 for basic colors). Moreover, numerical attributes for color, size and style must be preceded by the corresponding sub-keyword, like in orange=255~165~0 x=setmask(x,"color",orange,"grid",...) In case of two or more attributes for one feature (e.g. "blue" and "red" together), the last attribute is used. ==> Please check the examples! They are fairly instructive.
Output:
xm n x k matrix, data provided with mask.

Note:

Example:
library("plot")
;
; == defining display and some data sets ==========
;
; create a display two rows x three columns
pic=createdisplay(2,3)
n=20
; generate some 3D data
;   x standard normal distributed
;   z density of the standard normal distribution
x=normal(n,3)
y=sort(x[,1]~cos(x[,1]))
z=sort(grid(-3|-3,0.4|0.4,16|16),1:2)
z=z~prod(pdfn(z),2)
;
; == no mask -> default black medium circles ======
;
x=setmask(x)
show(pic,1,1,x)
;
; == huge orange grids -> setmask takes rgb =======
;
; create orange as RGB color and change the layout ofx
orange=255~165~0
x=setmask(x,"color",orange,"grid","huge")
show(pic,1,2,x)
;
; == two groups of points =========================
;
; the first half of the points(1 - n/2) will become
; "cyan fillcircle", the second half(n/2+1 - n) red
; crosses
mycolor=string("cyan",1:n/2)|string("red",n/2+1:n)
mystyle=string("fillcircle",1:n/2)|string("cross",n/2+1:n)
; the "reset" command deletes all old settings
x=setmask(x,"reset",mycolor,mystyle)
show(pic,1,3,x)
;
; == thick blue line, red left positioned text ====
;
mytext=string(" ",1:n) ; -> all strings blank
mytext[n]="cosine"     ; -> but last = "cosine"
y=setmask(y,"reset","line","blue","thick","text",mytext,"left","red")
show(pic,2,1,y)
;
; == red thin surface, green small filled rhombs ==
;
z=setmask(z,"reset","green","small","fillrhomb","surface","red","thin")
show(pic,2,2,z)
setgopt(pic,2,2,"title","ROTATE!")
;
; == differently colored numbers in circles  ======
;
; We create texts containing the numbers from 1 to n.
; Colors to the text are assigned by modulo division
; such that the colors runs from 0 to 6(7 = white is
; omitted)
mytext=string("%1.0f",1:n)  ; -> text = numbers
mycolor=(1:n)%7             ; -> numeric colors
x=setmask(x,"reset","circle","huge","text",mytext,"color",mycolor,"size",11)
show(pic,2,3,x)

Result:
Creates a display with six plots.

The upper left window
shows a 3-dimensional data set in the default view
of the XploRe graphics as black circle.

The upper middle window uses an orange "grid" instead of the
black circles.

In the upper right window, the first half of
the points is displayed as cyan filled circles and the
second half as red crosses.

The lower right
window represents the data as large black circles with colored
text in them.

The lower middle window shows the graph of the density
function.

If you click with the mouse in any of the windows
mentioned before, you can rotate the data or graph
with the cursor keys.

In the lower left window, we see the cosine function (2D)
plotted as thick blue line with "cosine" written in red to the
left of the last line point.



Author: M. Mueller, S. Klinke, 20020409
(C) MD*TECH Method and Data Technologies, 05.02.2006