Reputation: 583
I'm currently struggling to wrap my head around the following objective:
I not even get the simple example working. So far I have:
df <- data.frame(xval = rep(1:5, 8),
yval = runif(40),
pval = rep(c(rep(1,5), rep(2, 5)),4),
plt = rep(c(rep("mag", 10), rep("ph", 10)), 2),
p = c(rep("p1", 20), rep("p2", 20))
)
ggplot(df, aes(xval, yval)) +
geom_line(aes(colour = pval)) +
facet_grid(plt~p)
Would very much appreciate your help.
Upvotes: 0
Views: 740
Reputation: 132706
Since pval
is not a factor variable you need to specify the grouping explicitly.
ggplot(df, aes(xval, yval)) +
geom_line(aes(colour = pval, group = pval)) +
facet_grid(plt~p)
Upvotes: 2