María Antonieta Sánchez Farrán
2013-Jul-31 18:13 UTC
[R] qgraph: how to create legend (scale) for edge thickness?
Hello R community, I am creating some network representations using the qgraph package (big thanks to Sacha Epskamp for developing it!). The package is very well documented, but I am unable to find how to create a legend (scale) for edge thickness. In one of his qgraph examples, Sacha shows such type of scale (fifth graph in http://sachaepskamp.com/qgraph/examples - scale for edge thickness relative to p-values). I have searched the documentation and it seems that a legend relates to the definition of node groups, so I am uncertain on which option/command I need to use for achieving what I need. I would also like to be able to select the values for which the scale is created too. If it is unclear, what I am looking for is to display this next to the network graph: probability edge thickness 1.0 display line with thickness for 1.0 0.8 display line with thickness for 0.8 0.6 display line with thickness for 0.6 0.4 display line with thickness for 0.4 My line of code for generating the network is the following: qgraph(Edges2,esize=7,nsize=12,gray=TRUE,layout="circular",filetype="pdf",width=5,height=5,vsize=11,label.prop=1.2,arrows=FALSE,border.color=c("red","red","blue","green","purple"),border.width=4,maximum=1.4,cut=0.0001) I would appreciate if somebody can help me out. Thanks, Maria Antonieta [[alternative HTML version deleted]]
Sacha Epskamp
2013-Aug-01 10:59 UTC
[R] qgraph: how to create legend (scale) for edge thickness?
Hi Maria, Thanks! I just happened to read this but normally don't read r-help. It is best to send specific questions on not well known packages to the maintainer directly. The example on my website is hardcoded in the package. I should really also add the option to make a legend like you want though. But what you could do is create a dummy graph with the same parameters to get the color en width of the lines and then just add that as a legend. The graphs are just base R graphics so you could add a legend directly to it or plot it in a separate panel using layout(), e.g.: library("qgraph") # Dummy plot to extract edge coloring: g <- qgraph(cbind(1:4,1:4,c(0.4,0.6,0.8,1)),esize=7,gray=TRUE,maximum=1.4,cut=0.0001,DoNotPlot=TRUE) # Colors: col <- g$graphAttributes$Edges$color # lwd: lwd <- g$graphAttributes$Edges$width # Original plot: qgraph(Edges2,esize=7,nsize=12,gray=TRUE,layout="circular",filetype="pdf",width=5,height=5,vsize=11,label.prop=1.2,arrows=FALSE,border.color=c("red","red","blue","green","purple"),border.width=4,maximum=1.4,cut=0.0001) # Add legend: legend("topright",legend=c(0.4,0.6,0.8,1),col=col,lwd=lwd,bty="n") Best, Sacha --- Sacha Epskamp, MSc Department of Psychological Methods University of Amsterdam Weesperplein 4, room 2.05 1018 XA Amsterdam The Netherlands http://www.sachaepskamp.com 2013/7/31 María Antonieta Sánchez Farrán <antosanf@gmail.com>> Hello R community, > > I am creating some network representations using the qgraph package (big > thanks to Sacha Epskamp for developing it!). The package is very well > documented, but I am unable to find how to create a legend (scale) for edge > thickness. In one of his qgraph examples, Sacha shows such type of scale > (fifth graph in http://sachaepskamp.com/qgraph/examples - scale for edge > thickness relative to p-values). I have searched the documentation and it > seems that a legend relates to the definition of node groups, so I am > uncertain on which option/command I need to use for achieving what I need. > I would also like to be able to select the values for which the scale is > created too. > > If it is unclear, what I am looking for is to display this next to the > network graph: > > probability edge thickness > 1.0 display line with thickness for 1.0 > 0.8 display line with thickness for 0.8 > 0.6 display line with thickness for 0.6 > 0.4 display line with thickness for 0.4 > > My line of code for generating the network is the following: > > qgraph(Edges2,esize=7,nsize=12,gray=TRUE,layout="circular",filetype="pdf",width=5,height=5,vsize=11,label.prop=1.2,arrows=FALSE,border.color=c("red","red","blue","green","purple"),border.width=4,maximum=1.4,cut=0.0001) > > I would appreciate if somebody can help me out. > > Thanks, > Maria Antonieta > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]