The easy way I can think of is to just use geom_line and stat_summary
ggplot(data = diamonds, mapping = aes(x = cut, y = depth)) + geom_line() + stat_summary(fun.y = "median", geom = "point", size = 3)
This will give a very similar plot. 
If I really want to use geom_pointrange, I first create a small dataset.
data = diamonds %>% group_by(cut) %>% summarise(min = min(depth), max = max(depth), median = median(depth)) ggplot(data, aes(x = cut, y = median, ymin = min, ymax = max)) + geom_linerange() + geom_pointrange()
This will create an accurate plot. Hope this helps! 
source share