r - Separate sizes for points and lines in geom_pointrange from ggplot -
using ggplot
's geom_pointrange()
function, how change size of point , thickness of line 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 , thick line p + geom_pointrange(fill='blue', color='grey', shape=21, size=5) # plot 2: small dot , thin line (i want small dot , thick line or vice versa) p + geom_pointrange(fill='blue', color='grey', shape=21, lwd=1, size=5)
plot 1:
plot 2:
can small dot thick line (or vice-versa)?
a workaround might plot line , point separate geoms using geom_point
, geom_errorbar
. unfortunately, real application involves jittering, point , interval end in different places (unless maybe can control jittering?).
i can find similar questions on (like this), don't directly answer one.
thanks!
you can use fatten
in combination size
:
p + geom_pointrange(fill='blue', color='grey', shape=21, fatten = 20, size = 5)
p + geom_pointrange(fill='blue', color='grey', shape=21, fatten = .5, size = 5)
s. ?geom_pointrange
:
fatten
multiplicative factor used increase size of middle bar in geom_crossbar() , middle point in geom_pointrange().