#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
			grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
	#
	}
t4 <- ranHiveData()
t4 <- ranHiveData(nx = 5)
plotHive(t4)
set.seed(55)#
test <- ranHiveData(nx = 4, ne = 5, desc = "Tiny 4D data set")#
out <- sumHPD(test, plot.list = TRUE)#
print(out)
#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
			grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
		#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
		#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
		#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
		#
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
	#
	}
#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
			grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
		#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
		#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
		#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
		#
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
	#
	}
#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
			grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
		#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
		#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
		#
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
	#
	}
#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
			grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
		#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
		#
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
	#
	}
#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
			grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
		#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
		#
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
	#
	}
#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
			grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
		#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
		#
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
	#
	}
}
#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
			grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
	print(data.frame(x0, y0, x1, y0))#
	#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
	#
	}
#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
			grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {	#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
		#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
			#
#
		} #
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		grid.curve(x0, y0, x1, y1,#
			default.units = "native", ncp = 5, square = FALSE,#
			gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
#
		} #
#
	#
	}
plotHive(test)
#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
#
	#
	}
test <- ranHiveData(nx = 2); plotHive(test)
#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
#
	#
	}
#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
#
	#
	}
#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
				#
				#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
		#
		#
			#
				#
				#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
				#
				#
			#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
#
	#
	}
#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
				#
				#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
#
			#
			#
			#
		#
		#
		#
		#
		#
		#
		#
			#
				#
				#
			#
#
	#
	#
		#
			#
		#
			#
			#
			#
			#
			#
			#
			#
				#
				#
				#
				#
				#
				#
			#
			#
			#
		#
		#
		#
		#
		#
#
		#
			#
				#
				#
			#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
#
	#
	}
#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
#
	#
	}
#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
#
	#
	}
test <- ranHiveData(nx = 3); plotHive(test)
test <- ranHiveData(nx = 4); plotHive(test)
#
#
plotHive <- function(HPD, dr.nodes = TRUE,#
	method = "abs", ...) {#
	#
	#
	#
	#
	#
	#
	#
	#
#
#
#
	if (!HPD$type == "2D") stop("This is not a 2D hive data set: use plot3dHive instead")		#
	chkHPD(HPD)#
	nx <- length(unique(HPD$nodes$axis))#
#
	if (nx == 1) stop("Something is wrong: only one axis seems to be present")#
#
	#
	#
	if ((method == "rank") | (method == "norm")) HPD <- manipAxis(HPD, method)#
#
	nodes <- HPD$nodes#
	edges <- HPD$edges#
	axis.cols <- HPD$axis.cols#
#
	#
	#
	if (method == "abs") m <- centerHole(HPD)#
	if (method == "norm") m <- HPD$center.hole#
	if (method == "rank") {m <- centerHole(HPD); m <- floor(m)}#
	nodes$radius <- nodes$radius + m#
	HPD$nodes$radius <- nodes$radius #
	#
	#
	#
	#
	#
	#
	#
	#
#
	nsf <- 0.25#
	p2cX <- function(r, theta) x <- r*cos(theta*2*pi/360)#
	p2cY <- function(r, theta) y <- r*sin(theta*2*pi/360)#
#
#
#
	#
	#
	if (nx == 2) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
	#
		r.st <- c(min1, min2) #
		axst <- c(0, 180)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2)#
		axend <- c(0, 180)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
		#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		#
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md),#
			name = "3DHivePlot")#
#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 8),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(180, length(n2$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
	#
	#
		#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if (nodes$axis[id1] == 1) { #
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
			if (nodes$axis[id1] == 2) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				}#
#
			if (nodes$axis[id2] == 1) { #
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
			if (nodes$axis[id2] == 2) {#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
				#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
	#
	#
	if (nx == 3) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
#
		r.st <- c(min1, min2, min3) #
		axst <- c(0, 120, 240)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3)#
		axend <- c(0, 120, 240)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(120, length(n2$radius)),#
				rep(240, length(n3$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
#
	#
	#
	if (nx == 4) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
#
		r.st <- c(min1, min2, min3, min4) #
		axst <- c(0, 90, 180, 270)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4)#
		axend <- c(0, 90, 180, 270)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(90, length(n2$radius)),#
				rep(180, length(n3$radius)),#
				rep(270, length(n4$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 270)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 270)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 90)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 90)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
	#
#
#
	#
	#
	if (nx == 5) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5) #
		axst <- c(0, 72, 144, 216, 288)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5)#
		axend <- c(0, 72, 144, 216, 288)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius, n5$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(72, length(n2$radius)),#
				rep(144, length(n3$radius)),#
				rep(216, length(n4$radius)),#
				rep(288, length(n5$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 288)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 288)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 216)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 216)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 144)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 144)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 72)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 72)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
#
#
#
	#
	#
	if (nx == 6) {#
		#
		n1 <- subset(nodes, axis == 1)#
		n2 <- subset(nodes, axis == 2)#
		n3 <- subset(nodes, axis == 3)#
		n4 <- subset(nodes, axis == 4)#
		n5 <- subset(nodes, axis == 5)#
		n6 <- subset(nodes, axis == 6)#
		max1 <- max(n1$radius)#
		max2 <- max(n2$radius)#
		max3 <- max(n3$radius)#
		max4 <- max(n4$radius)#
		max5 <- max(n5$radius)#
		max6 <- max(n6$radius)#
		min1 <- min(n1$radius)#
		min2 <- min(n2$radius)#
		min3 <- min(n3$radius)#
		min4 <- min(n4$radius)#
		min5 <- min(n5$radius)#
		min6 <- min(n6$radius)#
#
		r.st <- c(min1, min2, min3, min4, min5, min6) #
		axst <- c(0, 60, 120, 180, 240, 300)#
		x0 = p2cX(r.st, axst)#
		y0 = p2cY(r.st, axst)#
#
		r.end <- c(max1, max2, max3, max4, max5, max6)#
		axend <- c(0, 60, 120, 180, 240, 300)#
		x1 = p2cX(r.end, axend)#
		y1 = p2cY(r.end, axend)#
	#
	#
	#
		md <- max(abs(c(x0, y0, x1, y1)))*1.2 #
		grid.newpage()#
		grid.rect(gp=gpar(fill="black"))#
		vp <- viewport(x = 0.5, y = 0.5, width = 1, height = 1,#
			xscale = c(-md, md), yscale = c(-md, md), name = "3DHivePlot")#
		pushViewport(vp)#
#
	#
	#
		grid.segments(x0, y0, x1, y1,#
			gp = gpar(col = HPD$axis.cols, lwd = 3),#
			default.units = "native")#
	#
	#
	#
		if (dr.nodes) {#
			r <- c(n1$radius, n2$radius, n3$radius, n4$radius,#
				n5$radius, n6$radius) #
			theta <- c(rep(0, length(n1$radius)),#
				rep(60, length(n2$radius)),#
				rep(120, length(n3$radius)),#
				rep(180, length(n4$radius)),#
				rep(240, length(n5$radius)),#
				rep(300, length(n6$radius)))#
			x = p2cX(r, theta)#
			y = p2cY(r, theta)#
			grid.points(x, y, pch = 20, gp = gpar(cex = nodes$size*nsf, col = nodes$color))#
			}#
#
	#
	grid.points(0, 0, pch = 20, gp = gpar(col = "gray"))#
#
	#
		#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = 0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 1) & (nodes$axis[id2] == 6)) {#
				th.st <- c(th.st, 0)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 300)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 6) & (nodes$axis[id2] == 5)) {#
				th.st <- c(th.st, 300)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 240)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 5) & (nodes$axis[id2] == 4)) {#
				th.st <- c(th.st, 240)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 180)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 4) & (nodes$axis[id2] == 3)) {#
				th.st <- c(th.st, 180)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 120)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
		#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 3) & (nodes$axis[id2] == 2)) {#
				th.st <- c(th.st, 120)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 60)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
	#
	#
		r.st <- r.end <- th.st <- th.end <- ecol <- ewt <- c()#
			#
		for (n in 1:nrow(edges)) {#
			#
			pat1 <- paste("\\b", edges$id1[n], "\\b", sep = "") #
			pat2 <- paste("\\b", edges$id2[n], "\\b", sep = "")#
			id1 <- grep(pat1, nodes$id)#
			id2 <- grep(pat2, nodes$id)#
			#
			if ((nodes$axis[id1] == 2) & (nodes$axis[id2] == 1)) {#
				th.st <- c(th.st, 60)#
				r.st <- c(r.st, nodes$radius[id1])#
				th.end <- c(th.end, 0)#
				r.end <- c(r.end, nodes$radius[id2])#
				}#
				#
			ecol <- c(ecol, edges$color[n])#
			ewt <- c(ewt, edges$weight[n])#
			}#
		#
		x0 = p2cX(r.st, th.st)#
		y0 = p2cY(r.st, th.st)#
		x1 = p2cX(r.end, th.end)#
		y1 = p2cY(r.end, th.end)#
#
		if (!length(x0) == 0) {#
			grid.curve(x0, y0, x1, y1,#
				default.units = "native", ncp = 5, square = FALSE,#
				gp = gpar(col = ecol, lwd = ewt), curvature = -0.5)#
			}#
#
		} #
#
	#
	}
test <- ranHiveData(nx = 5); plotHive(test)
test <- ranHiveData(nx = 6); plotHive(test)
getwd()
Sweave("HiveR.Rnw")
?HPD
#
#
dot2HPD <- function (file = NULL, node.inst = NULL, edge.inst = NULL,#
	axis.cols = NULL, center.hole = 0.15,#
	type = "2D", desc = NULL, ...) {#
	#
#
#
#
#
#
#
	#
	#
	#
	#
#
#
    lines <- readLines(file, ...)#
 	lines <- lines[grep(";", lines)] #
 	lines <- gsub("^[[:space:]]|[[:space:]]$", "", lines) #
	lines <- sub(";", "", lines)#
	#
#
#
    ed <- lines[grep("--|->", lines)]#
#
#
#
    no <- lines[-grep("--|->", lines)]#
    no <- unique(no)#
#
#
#
	HPD <- list()#
	HPD$nodes$id <- 1:length(no)#
	HPD$nodes$lab <- gsub("\\[.*\\]$", "", no) #
	HPD$nodes$lab <- gsub("[[:space:]]", "", HPD$nodes$lab) #
	HPD$nodes$axis <- rep(1, length(no))#
	HPD$nodes$radius <- rep(1, length(no))#
	HPD$nodes$size <- rep(1, length(no))#
	HPD$nodes$color <- rep("transparent", length(no))#
#
#
#
#
	at <- sub("^.*\\[", "", no)#
	at <- sub("\\]$", "", at)#
	at <- unlist(strsplit(at, ",", fixed = TRUE))#
	at <- strsplit(at, "=", fixed = TRUE)#
	dot.tag <- dot.val <- c()#
	for (n in 1:length(at)) dot.tag[n] <- at[[n]][1]#
	for (n in 1:length(at)) dot.val[n] <- at[[n]][2]#
	dot.tag <- gsub("[[:space:]]", "", dot.tag) #
	dot.val <- gsub("[[:space:]]", "", dot.val)#
#
	ni <- read.csv(node.inst) #
#
	for (n in 1:length(no)) { #
		for (i in 1:nrow(ni)) {#
			if ((dot.tag[n] == ni$dot.tag[i]) & (dot.val[n] == ni$dot.val[i])) {#
				#
				#
				#
				#
				if (ni$hive.tag[i] == "axis") {#
					HPD$nodes$axis[n] <- as.numeric(as.character(ni$hive.val[i]))#
					}#
				if (ni$hive.tag[i] == "radius") {#
					HPD$nodes$radius[n] <- as.numeric(as.character(ni$hive.val[i]))#
					}#
				if (ni$hive.tag[i] == "size") {#
					HPD$nodes$size[n] <- as.numeric(as.character(ni$hive.val[i]))#
					}#
				if (ni$hive.tag[i] == "color") {#
					HPD$nodes$color[n] <- as.character(ni$hive.val[i])#
					}#
				}#
			}#
		}#
 #
#
#
	#
	HPD$edges$id1 <- rep(1, length(ed))#
	HPD$edges$id2 <- rep(1, length(ed))#
	HPD$edges$weight <- rep(1, length(ed))#
	HPD$edges$color <- rep("gray", length(ed))#
#
#
#
#
#
#
	ed_prs <- sub("\\[.*$", "", ed) #
	ed_prs <- gsub("[[:space:]]", "", ed_prs) #
#
	for (n in 1:(length(ed_prs))) {#
		pat1 <- sub("(--|->).*$", "", ed_prs[n])#
		pat2 <- sub("^.*(--|->)", "", ed_prs[n])#
		pat1 <- paste("\\b", pat1, "\\b", sep = "") #
		pat2 <- paste("\\b", pat2, "\\b", sep = "") #
		HPD$edges$id1[n] <- grep(pat1, HPD$nodes$lab)#
		HPD$edges$id2[n] <- grep(pat2, HPD$nodes$lab)#
		}#
#
#
#
#
	at <- sub("^.*\\[", "", ed) #
	at <- sub("\\]$", "", at) #
	at <- unlist(strsplit(at, ",", fixed = TRUE))#
	at <- strsplit(at, "=", fixed = TRUE)#
	dot.tag <- dot.val <- c()#
	for (n in 1:length(at)) dot.tag[n] <- at[[n]][1]#
	for (n in 1:length(at)) dot.val[n] <- at[[n]][2]#
	dot.tag <- gsub("[[:space:]]", "", dot.tag) #
	dot.val <- gsub("[[:space:]]", "", dot.val)#
#
	ei <- read.csv(edge.inst) #
#
	for (n in 1:length(ed)) { #
		for (i in 1:nrow(ei)) {#
			if ((dot.tag[n] == ei$dot.tag[i]) & (dot.val[n] == ei$dot.val[i])) {#
				#
				#
				#
				#
				if (ei$hive.tag[i] == "weight") {#
					HPD$edges$weight[n] <- as.numeric(as.character(ei$hive.val[i]))#
					}#
				if (ei$hive.tag[i] == "color") {#
					HPD$edges$color[n] <- as.character(ei$hive.val[i])#
					}#
				}#
			}#
		}#
 #
#
	#
	HPD$nodes <- as.data.frame(HPD$nodes)#
	HPD$edges <- as.data.frame(HPD$edges)#
	#
	if (is.null(desc)) desc <- "No description provided"#
	HPD$desc <- desc#
	#
	if (is.null(axis.cols)) axis.cols <- brewer.pal(length(unique(HPD$nodes$axis)), "Set1")#
	HPD$axis.cols <- axis.cols#
	#
	HPD$center.hole <- center.hole#
	HPD$nodes$axis <- as.integer(HPD$nodes$axis)#
	HPD$nodes$size <- as.integer(HPD$nodes$size)#
	HPD$nodes$color <- as.character(HPD$nodes$color)#
	HPD$nodes$lab <- as.character(HPD$nodes$lab)#
	#
	HPD$edges$id1 <- as.integer(HPD$edges$id1)#
	HPD$edges$id2 <- as.integer(HPD$edges$id2)#
	HPD$edges$weight <- as.integer(HPD$edges$weight)#
	HPD$edges$color <- as.character(HPD$edges$color)#
	#
	HPD$axes <- length(unique(HPD$nodes$axis))#
	HPD$type <- type#
	#
	class(HPD) <- "HivePlotData"#
	#
    HPD#
	}
DTH <- read.csv("/Users/bryanhanson/Desktop/DTH Project/EndowmentSFR.csv")#
#
#
NT <- DTH$NetTuition#
EPS <- DTH$EPS#
SFR <- DTH$SFR#
#
WL <- DTH$Load#
WL <- as.integer(as.character(WL))#
#
Inst <- DTH$Institution#
cols <- rep(NA, length(WL)) #
#
for (n in 1:length(WL)) {#
	if (is.na(WL[n])) next#
	if (WL[n] == 4) cols[n] <- "green"#
	if (WL[n] == 5) cols[n] <- "orange"#
	if (WL[n] == 6) cols[n] <- "red"#
	}#
#
#
#
dth <- data.frame(NT, EPS, SFR, WL)#
dth <- na.omit(dth)#
#
#
#
pcaNS <- prcomp(dth, retx = TRUE, scale. = FALSE)#
plot(pcaNS) #
NSdf <- as.data.frame(pcaNS$x)#
NSdf <- cbind(NSdf, WL = dth$WL)#
#
#
#
p <- qplot(x = PC1, y = PC2, data = NSdf, geom = "point",#
	color = as.factor(WL), main = "Score Plot (no scaling)")#
print(p)
p <- p + geom_text()
printP
print(p)
DTH <- read.csv("/Users/bryanhanson/Desktop/DTH Project/EndowmentSFR.csv")#
#
#
NT <- DTH$NetTuition#
EPS <- DTH$EPS#
SFR <- DTH$SFR#
#
WL <- DTH$Load#
WL <- as.integer(as.character(WL))#
#
Inst <- DTH$Institution#
cols <- rep(NA, length(WL)) #
#
for (n in 1:length(WL)) {#
	if (is.na(WL[n])) next#
	if (WL[n] == 4) cols[n] <- "green"#
	if (WL[n] == 5) cols[n] <- "orange"#
	if (WL[n] == 6) cols[n] <- "red"#
	}#
#
#
#
dth <- data.frame(NT, EPS, SFR, WL, Inst)#
dth <- na.omit(dth)#
#
#
#
pcaNS <- prcomp(dth[,1:4], retx = TRUE, scale. = FALSE)#
plot(pcaNS) #
NSdf <- as.data.frame(pcaNS$x)#
NSdf <- cbind(NSdf, WL = dth$WL, Inst = dth$Inst)#
#
#
#
p <- qplot(x = PC1, y = PC2, data = NSdf, geom = "point",#
	color = as.factor(WL), main = "Score Plot (no scaling)")#
p <- p + geom_text(Inst)#
print(p)
p <- p + geom_text(x = PC1, y = PC2, label = Inst)#
print(p)
p <- p + geom_text(x = PC1, y = PC2, label = Inst, data = NSdf)#
print(p)
p <- qplot(x = PC1, y = PC2, data = NSdf, geom = "point",#
	color = as.factor(WL), main = "Score Plot (no scaling)")#
p <- p + geom_text(x = PC1, y = PC2, label = Inst, data = NSdf)#
print(p)
NSdf
