I'm trying to plot such chart in r by using ggplot using shape = 1 in geom_point, but the line crosses the points. I want the line to connect the points without crossing them.
Asked
Active
Viewed 864 times
0
-
I'm not sure what you mean by *"the line crosses the points"*. I don't see any lines crossing any points in the image you link to. We need a [minimal & reproducible code example with sample data](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Maurits Evers May 31 '18 at 23:16
1 Answers
0
You can use
dt = data.frame(x=1:5, y=sample(5))
library(ggplot2)
library(cowplot)
ggplot(dt, aes(x,y)) +
geom_line(size=2, color='darkgreen') +
geom_point(size=4, shape=21, color = 'darkgreen', fill='white', stroke = 2)
I.e. plot the points over the line, and give them a fill color.

dww
- 30,425
- 5
- 68
- 111