[R] rGraphviz: Changing edge label font size
nick harding
nicholas.harding at postgrad.manchester.ac.uk
Mon Apr 12 14:15:46 CEST 2010
Dear all,
Using rGraphviz, I would like to make my edge labels a smaller size than
the node labels, but I am unable to change the font size of edge labels
independently of node labels. The edge labels always seem to use the
font size defined for nodes.
I have searched the archives and found a similar query, but it received
no replies. http://www.mail-archive.com/r-help@r-project.org/msg45413.html
Thanks in advance for any help. Or would this query be better suited to
a graphviz mailing list?
Nick
Sample code follows.
#code
##Test Code to illustrate edge labels code
MAT<-matrix(0,8,8)
MAT[1,2]<-1
MAT[2,3]<-1
MAT[2,4]<-1
MAT[3,5]<-1
MAT[5,1]<-1
MAT[7,5]<-1
MAT[6,5]<-1
MAT[8,5]<-1
MAT<-MAT+t(MAT)
library("Rgraphviz")
g1<-new("graphAM", MAT,"undirected")
g1<-as(g1,"graphNEL") #convert to graphNEL
nodes(g1) <- letters[1:8]
nAttrs <- list()
eAttrs <- list()
nodeLabels<-letters[1:8]
names(nodeLabels)=nodes(g1)
#Define node attributes
nAttrs$label<-nodeLabels
##Define Edge Attributes
x<-length(edgeNames(g1))
edgeLabels <- signif(runif(x, 0, 1),1)
names(edgeLabels)<-edgeNames(g1)
eAttrs$label <-edgeLabels
##Define general attributes
attrs <- list(node = list(shape = "box", fixedsize = FALSE))
attrs$edge$fontsize<-8
attrs$node$fontsize<-32
#colour can be changed
attrs$node$fontcolor<-"blue"
attrs$edge$fontcolor<-"red"
##Plot
plot(g1,nodeAttrs = nAttrs, edgeAttrs = eAttrs, attrs = attrs,"neato")
More information about the R-help
mailing list