[R] ggplot2::geom_path() in a loop problems.
Martin Møller Skarbiniks Pedersen
tr@xp|@yer @end|ng |rom gm@||@com
Sat Apr 24 23:21:01 CEST 2021
On Fri, 23 Apr 2021 at 20:51, Chris Evans <chrishold using psyctc.org> wrote:
>
> I may be quite wrong but isn't the for loop in the second example simply
overwriting/replacing the first p2 with the second whereas the p1 version
is adding the paths to p1.
>
> (If you see what I mean, I don't think I have expressed that very well.)
>
> Very best (all),
>
> Chris
Hi Chris,
Thanks for your email. However I don't think that is the problem.
Same problem here:
library(ggplot2)
df <- data.frame(x = c(0,25,0,-25,0), y = c(25,0,-25,0,25))
p1 <- ggplot()
p1 <- p1 + geom_path(data = df,aes(x = x/1, y = y/1))
p1 <- p1 + geom_path(data = df,aes(x = x/2, y = y/2))
p1 <- p1 + xlim(-30,30)
p1 <- p1 + ylim(-30,30)
p1
df <- data.frame(x = c(0,25,0,-25,0), y = c(25,0,-25,0,25))
p3 <- ggplot()
idx <- 1
p3 <- p3 + geom_path(data = df,aes(x = x/idx, y = y/idx))
idx <- 2
p3 <- p3 + geom_path(data = df,aes(x = x/idx, y = y/idx))
p3 <- p3 + xlim(-30,30)
p3 <- p3 + ylim(-30,30)
p3
[[alternative HTML version deleted]]
More information about the R-help
mailing list