[statnet_help] An error on gplot.target() function (fwd)

Carter T. Butts buttsc at uci.edu
Sat Mar 21 11:53:18 PDT 2020


Hi, Hakan (by way of Martina):

A fix will be in the next sna release, but in the meantime I've attached
a modified version of gplot.target (suitable for source()ing) that will
fix the spurious warnings regarding circ.lab.  I'm not able to reproduce
the failure to draw the plot, however.  If there's a reproducible
example of that, I'll take a look.

Hope that helps,

-Carter

On 3/21/20 10:31 AM, martina morris wrote:

>

> Hi,

>

> I am working on a SNA project and using statnet. I am having an error,

> I couldn't find any contact information on statnet

> website. I found your e-mail at statnet package document on CRAN.

>

> Following code;

> sna::gplot.target(g, closeness(g), main="Degree",  circ.lab = FALSE,

>                   circ.col="skyblue", usearrows = FALSE,

>                   circ.lab.col = "white",

>                   vertex.col=c("blue", rep("red", 32), "yellow"),

>                   edge.col="darkgray", displaylabels = TRUE,

>                   label = netfriends_myk %v% "alias", label.cex=0.5,)

>

> develops this warning;

> In doTryCatch(return(expr), name, parentenv, handler) : "circ.lab" is

> not a graphical parameter

>

> and in some cases does not draw the plot.

>

> Can you help me on this issue or point to someone who can help?

>

> Thanks.

>

> Hakan

>

>

> _______________________________________________

> statnet_help mailing list

> statnet_help at u.washington.edu

> http://mailman13.u.washington.edu/mailman/listinfo/statnet_help

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman13.u.washington.edu/pipermail/statnet_help/attachments/20200321/11efaf01/attachment.html>
-------------- next part --------------
#Modified version of gplot.target that fixes a spurious warning; to appear in
#sna version 2.6
#
#CTB, 3/21/20
#
gplot.target<-
function (dat, x, circ.rad = (1:10)/10, circ.col = "blue", circ.lwd = 1,
circ.lty = 3, circ.lab = TRUE, circ.lab.cex = 0.75, circ.lab.theta = pi,
circ.lab.col = 1, circ.lab.digits = 1, circ.lab.offset = 0.025,
periph.outside = FALSE, periph.outside.offset = 1.2, ...)
{
offset <- min(0.5, sum(x == max(x))/(length(x) - 1))
xrange <- diff(range(x))
xmin <- min(x)
x <- 1 - (x - xmin)/(xrange + offset)
circ.val <- (1 - circ.rad) * (xrange + offset) + xmin
cl <- match.call()
if (is.null(cl$layout.par))
cl$layout.par <- list(radii = x)
else cl$layout.par$radii <- x
cl$layout.par$periph.outside <- periph.outside
cl$layout.par$periph.outside.offset <- periph.outside.offset
cl$x <- NULL
cl$circ.rad <- NULL
cl$circ.col <- NULL
cl$circ.lwd <- NULL
cl$circ.lty <- NULL
cl$circ.lab.theta <- NULL
cl$circ.lab.col <- NULL
cl$circ.lab.cex <- NULL
cl$circ.lab.digits <- NULL
cl$circ.lab.offset <- NULL
cl$periph.outside <- NULL
cl$periph.outside.offset <- NULL
cl$circ.lab <- NULL
cl$mode <- "target"
cl$xlim = c(-periph.outside.offset, periph.outside.offset)
cl$ylim = c(-periph.outside.offset, periph.outside.offset)
cl[[1]] <- match.fun("gplot")
coord <- eval(cl)
if (length(circ.col) < length(x))
circ.col <- rep(circ.col, length = length(x))
if (length(circ.lwd) < length(x))
circ.lwd <- rep(circ.lwd, length = length(x))
if (length(circ.lty) < length(x))
circ.lty <- rep(circ.lty, length = length(x))
for (i in 1:length(circ.rad)) segments(circ.rad[i] * sin(2 *
pi/100 * (0:99)), circ.rad[i] * cos(2 * pi/100 * (0:99)),
circ.rad[i] * sin(2 * pi/100 * (1:100)), circ.rad[i] *
cos(2 * pi/100 * (1:100)), col = circ.col[i], lwd = circ.lwd[i],
lty = circ.lty[i])
if (circ.lab)
text((circ.rad + circ.lab.offset) * cos(circ.lab.theta),
(circ.rad + circ.lab.offset) * sin(circ.lab.theta),
round(circ.val, digits = circ.lab.digits), cex = circ.lab.cex,
col = circ.lab.col)
invisible(coord)
}



More information about the statnet_help mailing list