rgraphviz: node attributes of a layout graph
0
0
Entering edit mode
@laurin-muller-3698
Last seen 10.6 years ago
Hi, i need to get the parameters (at least coordinates) of a graph after layouting it with Rgraphviz. i am trying to add a rectangle to every node in a graph. for a "simple" graph it works fine (i.e. for the first node): g <- randomGraph(letters[1:10], 1:4, 0.2) plot(g, main = "Example Graph") gl <- agopen(g,name="name") gv <- AgNode(gl) x<-getNodeXY(gv[[1]])$x y<-getNodeXY(gv[[1]])$y rect(x+30,y,x+40,y+30) but after layouting the graph i get the old coordinates (before layouting) for the graph nodes: names(nLabels)?<-?nLabels?<-?nodes(g) nBorderCols <- rainbow(length(nLabels)) names(nBorderCols) <- names(nLabels) attrs?=?list(node=list(fixedsize=FALSE),graph=list(rankdir="LR")) nodeRenderInfo(g) <- list(label=nLabels, col=nBorderCols) g <- layoutGraph(g,?attrs=attrs) g<-renderGraph(g) x<-getNodeXY(gv[[1]])$x y<-getNodeXY(gv[[1]])$y rect(x+30,y,x+40,y+30) i had a look at wolfgang hubers imageMap function and tried to recalculate the usr coordinates but that does not work: usr <- par("usr") w <- getY(upRight(boundBox(gl))) h <- getX(upRight(boundBox(gl))) x.u2p = function(x) {(x-usr[1])/diff(usr[1:2])*w} y.u2p = function(y) {(usr[4]-y)/diff(usr[3:4])*h} x <- x.u2p(x) y <- y.u2p(y) rect(x,y,x+10,y+30) i am missing something here but do not have a clue were. thanks in advance, Laurin ------------------------------------------ Dipl.-Ing. Laurin Mueller University Assistant at the Institute for Bioinformatics and Translational Research UMIT - University for Health Sciences, Medical Informatics and Technology Eduard Wallnoefer-Zentrum 1, 6060 Hall in Tyrol, Austria T +43(0)50 8648 3868, F + 43(0)50 8648 673868 E laurin.mueller at umit.at, W http://bioinf.umit.at
graph Rgraphviz graph Rgraphviz • 1.1k views
ADD COMMENT

Login before adding your answer.

Traffic: 572 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6