使用ggplot叠加具有不同颜色的图形

时间:2016-09-12 02:54:10

标签: r ggplot2

我有两张图,我需要用两种不同的颜色覆盖它们。

a <- matrix(c(0,0,1,0,1,1,0,1), ncol = 2 ,byrow = T)
b <- .5*matrix(c(0,0,1,0,1,1), ncol = 2 ,byrow = T)
p1 <- ggplot()
p1 <- p1 + geom_polygon(data = data.frame(a), aes(a[,1], a[,2]), fill = NA, col = "black") 
p2 <- ggplot()
p2 <- p2 + geom_polygon(data = data.frame(b), aes(b[,1], b[,2]), fill = NA, col = "red") 
p2

0 个答案:

没有答案