How do I set the line type for "blank points connected by lines"?

I want to make a plot ggplot2

like this

base

x <- 1:10
y <- rnorm(10) + x
df <- data.frame(x=x,y=y)
plot(x,y)
lines(x,y,type='c')

      

I like this style type='c'

, R help tell me

"c" for empty points connected by lines

but how can i implement this type in ggplot2

?

library(ggplot2)
ggplot(data=df,aes(x=x,y=y)) + geom_line() + geom_point(shape=21,size=3)

      

ggplot

I mean, how do I make the space between blank dots and lines? which one linetype

should I choose?

Many thanks

+3


source to share


1 answer


ggplot(data=df,aes(x=x,y=y)) + 
    geom_line() +  
    geom_point(shape=21, size=5, colour="white", fill="white") + 
    geom_point(shape=21,size=3) + 
    theme_bw()

      



enter image description here

+4


source







All Articles