许多R包的六角标是怎么画出来的?

写在前面

许多R包又有其六角标,这是可以通过R语言画出来的,下面我已ggClusternet为例子做一个。借鉴了ggrgl的绘图代码和颜色风格。话不多说直接上代码:

library(ggplot2)r = 10theta <- seq(0, 2*pi, length.out = 7) + pi/2hex <- data.frame( x = r * cos(theta), y = r * sin(theta))left <- hex[c(1, 2, 3, 4, 1),]right <- hex[c(4, 5, 6, 1, 4),]centroid <- c(5.75, 0)mid_14 <- colSums(hex[c(1,4),])/2mid_1cent <- colSums(rbind(hex[1,], centroid))/2mid_4cent <- colSums(rbind(hex[4,], centroid))/2north <- rbind(hex[c(1, 6),], centroid)south <- rbind(hex[c(4, 5),], centroid)east <- rbind(hex[c(6, 5),], centroid)west <- rbind(hex[c(4, 1),], centroid)west1 <- as.data.frame(rbind(mid_14, mid_1cent, mid_4cent))west2 <- as.data.frame(rbind(centroid, mid_1cent, mid_4cent))
sand <- '#ebd5a8'green <- '#1d814a'dark <- 'grey20'p <- ggplot() + # geom_polygon(data = hex , aes(x, y)) + geom_polygon(data = left , aes(x, y), colour=NA) + geom_polygon(data = north, aes(x, y), colour=NA, fill = sand) + geom_polygon(data = south, aes(x, y), colour=NA, fill = sand) + geom_polygon(data = east , aes(x, y), colour=NA, fill = dark) + geom_polygon(data = west , aes(x, y), colour=NA, fill = green) + geom_polygon(data = west1, aes(x, y), colour=NA, fill = sand) + geom_polygon(data = west2, aes(x, y), colour=NA, fill = dark) + annotate('text', x=-8.1, y= 2, label = toupper("Network " ), hjust = 0, colour = green, size = 8, family = 'Futura-Medium') + annotate('text', x=-8.1, y=-0, label = toupper("with cluster" ), hjust = 0, colour = green, size = 8, family = 'Futura-Medium') + annotate('text', x=-8.1, y=-2, label = toupper("of microbiome"), hjust = 0, colour = green, size = 8, family = 'Futura-Medium') + annotate('text', x= 1.95, y=0, label = "ggClu", colour = green, size = 12, family = 'Futura-CondensedMedium') + annotate('text', x= 5.9, y=0, label = "sterNet", colour = sand, size = 12, family = 'Futura-CondensedMedium') + theme_void() + coord_equal() + theme(rect = element_rect(fill = "transparent", colour = NA))pggsave("./logo.png", width = 9, height = 8)
(0)

相关推荐