Separate sizes for points and lines in geom_pointrange from ggplot

Using the ggplot geom_pointrange() function, how do I resize the point size and line thickness separately?

Example:

 # make test data df <- data.frame(y=10, ymin=1, ymax=20, x=1) # store ggplot object p <- ggplot(data=df, aes(y=y, ymin=ymin, ymax=ymax, x=x)) # plot 1: big dot and thick line p + geom_pointrange(fill='blue', color='grey', shape=21, size=5) # plot 2: small dot and thin line (I want small dot and thick line or vice versa) p + geom_pointrange(fill='blue', color='grey', shape=21, lwd=1, size=5) 

Section 1:

enter image description here

Section 2:

enter image description here

Is it possible to get a small dot with a thick line (or vice versa)?

A workaround may be to build a line and point out as separate geometers using geom_point and geom_errorbar . Unfortunately, my real application is related to jitter, so the point and interval end in different places (if, perhaps, I can not control jitter?).

I can find similar questions on SO ( like this ), but they do not directly answer this question.

Thanks!

+6
source share
1 answer

You can use fatten in combination with size :

 p + geom_pointrange(fill='blue', color='grey', shape=21, fatten = 20, size = 5) 

enter image description here

 p + geom_pointrange(fill='blue', color='grey', shape=21, fatten = .5, size = 5) 

enter image description here

from. ?geom_pointrange :

to feed
The multiplicative factor used to increase the size is the middle bar in geom_crossbar () and the midpoint in geom_pointrange ().

+9
source

All Articles