首先我会说我只是在学习ggplot2
,这是我从别人那里继承的代码。我facet_wrap
用来并排创建两个图表。然后我geom_path
用来在每个图中绘制一个形状,但我希望每个图中都有一个不同的形状。现在我只能在每个图中获得相同的形状,或者在两个图中都获得两个形状。所以基本上需要对一个方面做点什么,而不是另一个方面。
这是我截断的代码:
#variables already defined
square1 <- data.frame(x=c(left, right, right, left, left),
y=c(bottom, bottom, top, top, bottom))
square2 <- data.frame(x=c(left2, right2, right2, left2, left2),
y=c(bottom2, bottom2, top2, top2, bottom2))
RE <- ggplot(data, aes(x, y))
RE <- RE + geom_point()
RE <- RE + xlab + ylab + ggtitle
RE <- RE + coord_cartesian()
RE <- RE + scale_colour_brewer()
RE <- RE + theme_bw()
RE <- RE + facet_wrap(~ v1 + v2, ncol=2)
RE <- RE + geom_path(aes(x = x, y = y), data = square1) + geom_path(aes(x = x, y = y), data = square2, linetype = 2)