In both plots the points look different, but why?
mya <- data.frame(a=1:100)
ggplot() +
geom_path(data=mya, aes(x=a, y=a, colour=2, size=seq(0.1,10,0.1))) +
geom_point(data=mya, aes(x=a, y=a, colour=1, size=1)) +
theme_bw() +
theme(text=element_text(size=11))
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))
?aes_linetype_size_shape explains …
# Size examples
# Should be specified with a numerical value (in millimetres),
# or from a variable source
But in my code it looks different.
There are a couple of confusing things happening in your code. You seem to be using the
aesfunction in a way that is not intended. As well as thesizeissue, you are getting multiple legends, and I think ggplot is confused about the colours.The
aesfunction is used to map aesthetics to variables in the data, but you are using it to set aesthetics to a constant. In addition, you are using theaesfunction to set two separate aesthetics. Even though you setsizeto a constant, ggplot2 does not like two separate (paths and points) size mappings. Further, you do the same with a colour mapping.sizeandcolourare set to constant values so move them outside theaesfunction. Also, with respect tosizeof the path in the first plot, it is probably safer to add asizevariable to the data frame. (I’ve modified your data a little so that both points and paths are visible.) And as expected, one legend in the first plot is drawn.