I want to plot a path and show where the datapoints are.
Combine Points with lines with ggplot2
uses geom_point() + geom_line()
but I do not like that the dots are much thicker and the lines have a discontinuous look - x - x ----- x ---
thus I decidet to
mya <- data.frame(a=1:20)
ggplot() +
geom_path(data=mya, aes(x=a, y=a, colour=2, size=1)) +
geom_point(data=mya, aes(x=a, y=a, colour=1, size=1)) +
theme_bw() +
theme(text=element_text(size=11))
I like that the dots and the line have the same size. I did not use the alpha channel because I fear trouble with the alpha channel when I include the files in other programs.
darker(FF0000) = AA0000
size=
parameter did not work as expected in R 2.15
Aesthetics can be set or mapped within a ggplot call.
In your case it appears you want to set the size to a single value. You can also use scale_..._manual(values = ..., guide = 'none')
to suppress the creation of a legend.
This appears to be what you want with colour
.
You can then use named colours such as lightblue
and darkblue
(see ?colors
for more details)
ggplot() +
geom_line(data=mya, aes(x=a, y=a, colour='light'), size = 2) +
geom_point(data=mya, aes(x=a, y=a, colour='dark'), size = 2) +
scale_colour_manual(values = setNames(c('darkblue','lightblue'),
c('dark','light')), guide = 'none') +
theme_bw()