plotmat {diagram} | R Documentation |
visualises a transition matrix as a number of (labeled) boxes connected by (labeled) arrows.
plotmat(A, pos=NULL, curve=NULL, name=NULL, absent=0, relsize=1, lwd=2, lcol="black" , box.size=0.1, box.type="circle", box.prop=1,box.col="white", box.lcol=lcol, box.lwd=lwd, shadow.size=0.01, shadow.col="grey", dr=0.01, dtext=0.3, self.lwd=1, self.cex=1, self.shiftx=box.size, self.shifty=NULL, arr.lwd=lwd, arr.lcol=lcol, arr.col="black", arr.type="curved", arr.pos=0.5, arr.length=0.4, arr.width=arr.length/2, endhead=FALSE, mx=0.0, my=0.0, box.cex=1, prefix="", cex.txt=1, add=FALSE, main="", ...)
A |
square coefficient matrix, specifying the links (rows=to,cols=from) |
pos |
vector, specifying the number of elements in each graph row, or a 2-column matrix with element position, or NULL |
curve |
one value, or a matrix, same dimensions as A, specifying the arrow curvature; 0 for straight; NA for default curvature |
name |
string vector, specifying the names of elements, dimension = number of rows (columns) of A |
absent |
all elements in A different from this value are connected |
relsize |
scaling factor for size of the graph |
lwd |
default line width of arrow and box |
lcol |
default color of arrow line and box line |
box.size |
size of label box |
box.type |
shape of label box (rect, ellipse, diamond, round, hexa, multi) |
box.prop |
length/width ratio of label box |
box.col |
fill color of label box |
box.lcol |
line color of label box |
box.lwd |
line width of the box |
shadow.size |
relative size of shadow of label box |
shadow.col |
color of shadow of label box |
dr |
size of segments, in radians, to draw ellipse (decrease for smoother) |
dtext |
controls the position of arrow text relative to arrowhead |
self.lwd |
line width of self-arrow, (arrow from i to i) |
self.cex |
relative size of self-arrow, relative to box |
self.shiftx |
relative shift of self-arrow, in x-direction |
self.shifty |
relative shift of self-arrow, in x-direction |
arr.lwd |
line width of arrow, connecting two different points |
arr.lcol |
color of arrow line |
arr.col |
color of arrowhead |
arr.type |
type of arrowhead (curved,triangle,circle,simple) |
arr.pos |
relative position of arrowhead on arrow segment/curve |
arr.length |
arrow length |
arr.width |
arrow width |
endhead |
if TRUE: the arrow line stops at the arrowhead; default =FALSE and arrow line continues beyond the arrow head |
mx |
horizontal shift of the boxes |
my |
vertical shift of the boxes |
box.cex |
relative size of text in boxes |
prefix |
to be added in front of non-zero arrow labels |
cex.txt |
relative size of arrow text |
add |
start a new plot (FALSE), or add to current plot (TRUE) |
main |
main title |
... |
other arguments passed to function shadowbox |
The square transition matrix A determines the number of elements of A (rows of A)
and which elements are connected (all values in A different from "absent").
A also provides the values of arrowlabels.
The position of the elements are specified with "pos", which is either NULL,
or a vector specifying the number of elements on a row, or a 2-columned matrix
specifying the (x,y) position of each element.
The ordering of elements is according to the row number of A
The offset from x-axis and from y-axis can be changed with mx and my
The name of each element is given by vector "name"; this name is written in
its respective box.
The relative size of this text can be changed by box.cex
If shadow is TRUE, a shadow is drawn, in the right-lower corner of the box,
its color and relative size specified with shadow.col and shadow.size respectively.
Both can be one value (equal shadows) or a vector, specifying one value for each box shadow.
The type of the box is set with "box.type" which can take on the values:
The length of the box is set with box.size, the proportionality (length/width) ratio with box.prop
The fill-color of the box is specified with box.col; the line width of the box with box.lwd and the line color with box.lcol;
All box properties can be either one value (equal boxes) or a vector, specifying one value for each box.
For all values A[i,j] of A wich are not equal to "absent", one arrow is
drawn *from* column-element j *to* the row-element i of A.
The curvature of this arrow is specified with matrix element curve[i,j],
where 'curve' is either NULL, one value, or has the same dimension as A.
A straight arrow has curvature 0, NA (the default) chooses a default curvature,
Positive or negative values of curve draws curved arrows.
If the arrow is curved, then dr is the increment used to draw the ellipse; set to a lower value for smoother lines.
The type of the arrowhead is set with "arr.type" which can take the values:
The line color and width of the arrow line is set with arr.lcol and arr.lwd
The size of the arrow head is specified with arr.length and arr.width,
the position of the arrow head is specified with arr.pos (value between [0,1]).
see Arrowhead
for details on arrow head
a list containing:
arr |
a data.frame with arrow information:
|
comp |
a matrix with the element position (centre of the boxes) |
radii |
the radiusses in x- and y-direction of the boxes |
rect |
the "xleft","ybot","xright",and "ytop" of the boxes - redundant |
Karline Soetaert <k.soetaert@nioo.knaw.nl>
shadowbox
,
Arrowhead
from package shape
try: demo(plotmat)
M <- matrix(nrow=4,ncol=4,byrow=TRUE,data=0) pp<-plotmat(M,pos=c(1,2,1),name=c("A","B","C","D"),lwd=1,box.lwd=2, cex.txt=0.8,box.size=0.1,box.type="square",box.prop=0.5, main="plotmat") M[2,1]<-M[3,1]<-M[4,2]<-M[4,3] <- "flow" pp<-plotmat(M,pos=c(1,2,1),curve=0,name=1:4,lwd=1,box.lwd=2,cex.txt=0.8, box.type="circle",box.prop=1.0,main="plotmat") diag(M) <- "self" pp<-plotmat(M,pos=c(2,2),curve=0,name=LETTERS[1:4],lwd=1,box.lwd=2, cex.txt=0.8,self.cex=0.5,self.shiftx=c(-0.1,0.1,-0.1,0.1), box.type="diamond",box.prop=0.5,main="plotmat") M <- matrix(nrow=4,ncol=4,data=0) M[2,1]<-1 ;M[4,2]<-2;M[3,4]<-3;M[1,3]<-4 pp<-plotmat(M,pos=c(1,2,1),curve=0.2,name=letters[1:4],lwd=1,box.lwd=2, cex.txt=0.8,arr.type="triangle",box.size=0.1,box.type="hexa", box.prop=0.5,main="plotmat") M <- matrix(nrow=4,ncol=4,byrow=TRUE,data=0) M <- as.data.frame(M) M[[2,1]]<- "k[si]" M[[3,1]]<- "k[N]" M[[4,2]]<- "sqrt(frac(2,3))" names <- c(expression(lambda[12]),"?",expression(lambda[13]),expression(lambda[23])) pp<-plotmat(M,pos=c(1,2,1),name=names,lwd=1,box.lwd=2, curve=0, cex.txt=0.8,box.size=0.1,box.type="square",box.prop=0.5, main="plotmat")