ruben baetens
ruben baetens

Reputation: 2926

Connect geom_points by lines wíth keeping distance

In ggplot2, I want to make an easy geom_point() scatter plot, with the dots connected by a line. However, I want the lines not to touch the point, as for example in this graph but I do not seem to manage at all in ggplot2.

Upvotes: 1

Views: 462

Answers (1)

Pierre
Pierre

Reputation: 578

This is a hack but this might help

enter image description here

x=1:20
y=rnorm(20)
data=data.frame(x,y)
library(ggplot2)

ggplot(data,aes(x,y))+
  geom_line()+
  geom_point(size=4,color="white")+
  geom_point()+
  theme_bw()

Upvotes: 1

Related Questions