I have the following initial situation: I have made the colour and shape of the points in a scatter plot dependent on the same variable. But because the points overlap, you can't see the individual data points very well, so I need a line.
My problem: I can't manage to give the different shapes an outer line in black without the colour of the whole point/traingle changing completely.
Here is my code, does anyone have any ideas?
ggplot(mydata, aes_string(x = "metric_var1", y = "metric_var2", shape = "categ_var"))
geom_point(aes(colour = categ_var), size = 3)
scale_colour_manual(values=c("#13678A", "#FFD579"))
Thanks already!
CodePudding user response:
You need to use a shape for geom_point()
that has a border, i.e. shapes 21-24.
The border is controled by the aesthetics color
and stroke
, the inside by fill
and size
.
ggplot(mydata, aes_string(x = "metric_var1", y = "metric_var2", shape = "categ_var"))
geom_point(aes(fill = categ_var), color = "black", size = 3)
scale_fill_manual(values=c("#13678A", "#FFD579"))
scale_shape_manual(values=21:22)