I'm a relative beginner with ggplot2, and I'm having a bit of a
problem. I'm using the code below to plot a graph, which has three
lines (for the three different values of Surface) and I want to add
vertical lines at three important x values. These lines appear, but I
used the colour parameter to tell them to be in grey, but that isn't
happening. They're appearing in a purple colour.
Also, a legend item called "gray80" gets added, as well as a separate
legend entitled "2", with just one entry called "2".
I must be doing something silly here. What is it?
Code:
library(ggplot2)
df = read.csv('Comparison Data.csv', header=T)
graph <- ggplot(df, aes(x = Wavelength, y = Diff, colour=Surface,
title="A graph - YAY!")) + geom_line()
graph <- graph + theme_set(theme_bw())
graph <- graph + geom_vline(aes(xintercept=c(545, 645, 825),
colour="grey80", size=2))
graph <- graph + labs(x = "Wavelength (nm)", y = "Percentage
Difference", colour= "Surface Type")
graph
Cheers,
Robin
If you are _setting_ the colour, it should not be inside the aesthetic
_mapping_ specification:
geom_vline(aes(xintercept=c(545, 645, 825)), colour="grey80", size=2)
Hadley
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> To post to this group, send email to ggp...@googlegroups.com
> To unsubscribe from this group, send email to
> ggplot2+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ggplot2
Of course - that's where I went wrong.
Thanks for your very prompt reply, and also for the great tool which
is ggplot2.
Kind regards,
Robin