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

Group: Plot Manipulation
See also: show getgopt

Function: setgopt
Description: Controls the layout of a display. First, the display should be created and shown. Then call setgopt to change its headline, the labels of its axes, limits, etc.

Usage: setgopt(di, l_num, c_num, gropt) or setgopt(di, l_num, c_num, optionname, optionvalue {, optionname1, optionvalue1} {, optionname2, optionvalue2} {...})
Input:
di string, name of a display
l_num integer, represents the number of a row of the display di
c_num integer, represents the number of a column of the display di
gropt special object that is obtained by the command gropt = getgopt(...) and which includes all graphic options from another display.
optionname string, specifies the option to be changed. Allowed are:
"title"
to change the headline of a plot,
"xlim"
to change the limits of the x-axis,
"ylim"
to change the limits of the y-axis,
"xoffset"
to change the width of the axis border,
"yoffset"
to change the height of the axis border,
"xvalue"
to change the values m and k of the transformation m+k*x (x-axis),
"yvalue"
to change the values m and k of the transformation m+k*y (y-axis),
"xorigin"
to change the coordinates of the origin for the tickmarks of the x-axis,
"yorigin"
to change the coordinates of the origin for the tickmarks of the y-axis,
"xmajor"
to change the major for the tickmarks of the x-axis,
"ymajor"
to change the major for the tickmarks of the y-axis,
"xlabel"
to change the label of the x-axis,
"ylabel"
to change the label of the y-axis,
"rotpoint"
to change the rotation point of the plot,
"rotcos"
to change the rotation cosinus matrix of the plot,
"border"
to control the frame around the plot,
"scal"
to change the scale matrix,
"transl"
to change the translation vector,
"xaxis"
to turn the x-axis either on (=1) or off (=0),
"yaxis"
to turn the y-axis either on (=1) or off (=0),
"zaxis"
to turn the z-axis either on (=1) or off (=0),
"fonttype"
to set the font type used for labels and title,
"dispsize"
to change the size of the window with display/graphs,
"disppos"
to change the position of the window with display/graphs.
optionvalue string, representing the new value for this option:
"title"
a string representing the title of the plot,
"xlim"
a vector that contains two values, e. g. 0 | 10, which represent the length of the x-axis,
"ylim"
a vector that contains two values, e. g. 0 | 10, which represent the length of the y-axis,
"xoffset"
a vector that contains two values to change the right and left widths of the axis border (in percent),
"yoffset"
a vector that contains two values to change the upper and lower heights of the axis border (in percent),
"xvalue"
a vector that contains two values to change m and k into m+k*x, e. g. 0 | 1 for 0+1*x,
"yvalue"
a vector that contains two values to change m and k into m+k*y, e. g. 0 | 1 for 0+1*y,
"xorigin"
a value specifying the location of the x-coordinate of the origin; usually 0.0,
"yorigin"
a value specifying the location of the y-coordinate of the origin; usually 0.0,
"xmajor"
a value for the major of the tickmarks of the x-axis; if it is zero, the description of the x-axis is omitted, if it is negative, the x-axis is not drawn at all,
"ymajor"
a value for the major of the tickmarks of the y-axis; if it is zero, the description of the y-axis is omitted, if it is negative, the y-axis is not drawn at all,
"xlabel"
a string to label the x-axis,
"ylabel"
a string to label the y-axis,
"rotpoint"
a rotation point vector,
"rotcos"
a rotation cosinus matrix,
"scal"
a diagonal scale matrix,
"transl"
a translation vector,
"border"
a boolean indicating whether the graph has a border (=1) or not (=0),
"xaxis"
a boolean indicating whether the x-axis should be drawn (=1) or not (=0),
"yaxis"
a boolean indicating whether the y-axis should be drawn (=1) or not (=0),
"zaxis"
a boolean indicating whether z-axis should be drawn (=1) or not (=0),
"fonttype"
a string indicating the font type that should be used for labels and title; possible options are: "s" or "serif" for a serif font, "ss" or "sansserif" for a sansserif font and "m" or "monospaced" for non-proportional font.

Note:

Example:
di=createdisplay(1, 1)
x=1:100
y=sin(x/20)+uniform(100, 1)/10
show(di, 1, 1, x~y, x~knn(y, 10))
setgopt(di, 1,1, "border", 0)   ; disable borders
print(di, "TEST.ps")            ; write PS file without border
setgopt(di, 1,1, "border", 1)   ; enable border(default)
print(di, "TEST2.ps")           ; PS file with border

Result:
Two Postscript-files, one with border and one
without
Example:
; title and axes labels
dis=createdisplay(1, 1)
x=1:100
y=sqrt(x)
data=x~y
show(dis, 1, 1, data)
setgopt(dis,1,1,"title","Plot of Sqrt(x)","xlabel","x","ylabel","y=sqrt(x)","dispsize",450|400,"disppos",20|20)
; varying xoffset and yoffset
library("xplore")
n       =       100
s1      =       1
s2      =       1
rho     =       0.3
ss      =       #(s1,rho)~#(rho,s2)
u       =       gennorm(n, #(0,0), ss)	; gen 2 dim normal data
d=createdisplay(2,2)
show(d,1,1,u)
setgopt(d,1,1,"title","very small offset","xlim",-4|4,"ylim",-4|4,"yoffset", 5|5, "xoffset", 5|5,"dispsize",450|400,"disppos",400|400)
show(d,1,2,u)
setgopt(d,1,2,"title","small  offset","xlim",-4|4,"ylim",-4|4,"yoffset", 10|10, "xoffset", 10|10)
show(d,2,1,u)
setgopt(d,2,1,"title","large offset ","xlim",-4|4,"ylim",-4|4,"yoffset", 15|15, "xoffset", 15|15)
show(d,2,2,u)
setgopt(d,2,2,"title","very large offset","xlim",-4|4,"ylim",-4|4,"yoffset", 20|20, "xoffset", 20|20)
;limits, majors and offsets
di=createdisplay(2, 2)
y=sin(x/20)+uniform(100, 1)/10
show(di, 1, 1, x~y)
show(di, 1, 2, x~y)
show(di, 2, 1, x~y)
show(di, 2, 2, x~y)
setgopt(di, 1, 1,"title","default")
setgopt(di, 1, 2,"title","ylim =(-4) | 4, xlim = 0 | 50", "ylim",(-4)|4,"xlim", 0|50,"dispsize",500|500,"disppos",600|25)
setgopt(di, 2, 1,"title","ymajor = 0.3, xmajor = 15","ymajor", 0.3,"xmajor", 15)
setgopt(di, 2, 2,"title","yoffset = 13 | 13, xoffset = 20 | 20", "yoffset", 13|13,"xoffset", 20|20)

Result:
Three different displays are shown that
demonstrate some of the possibilities of setgopt.



(C) MD*TECH Method and Data Technologies, 05.02.2006