Description
(This is super similar to this past issue #1389, but the addition of bidirectional geoms in v3.3.0 have changed the circumstances of that original issue)
Since ggplot2 3.3.0, geoms like geom_boxplot()
and geom_pointrange()
work with either the x or the y aesthetic, thus eliminating the need for packages like {ggstance} for horizontal point ranges:
library(ggplot2)
df <- data.frame(x = 1:3, y = 1:3)
ggplot(df, aes(x = x, y = y, color = factor(x))) +
geom_pointrange(aes(xmin = x - 1, xmax = x + 1))
Currently, however, the legend keys for point ranges show vertical lines regardless of the direction of the actual point range. There are ways to adjust the legend keys by either modifying some of the underlying grid grobs, or by adding an empty stat_summary()
layer in combination with geom_point()
and geom_line()
(example), but these are fairly hacky.
In a previous issue #1389, the official recommendation from Hadley was to use ggstance, but now that geom_pointrange()
can go an any direction now since v3.3.0, it would be neat if the legend glyphs matched the direction of the geoms for things like point ranges and box plots. I have no idea how feasible or difficult that would be though.
Thanks!