wilkelab / ungeviz

Tools for visualizing uncertainty with ggplot2
158 stars 8 forks source link

suggested fix for geom_hpline() for newer versions of ggplot2 #3

Open remomomo opened 10 months ago

remomomo commented 10 months ago

Hi, I've recently installed the latest version of R and ggplot2, and noticed that my plots have changed. I suspect it has something to do with the change in how the width of lines is handled by ggplot2 (https://www.tidyverse.org/blog/2022/11/ggplot2-3-4-0/).

Instead of size, newer versions of ggplot2 require the use of linewidth for specifying line thickness.

For geom_hpline(), this seems to have done the trick:

GeomHpline <- ggproto("GeomHpline", GeomSegment,
  required_aes = c("x", "y"),
  non_missing_aes = c("linewidth", "colour", "linetype", "width"), # "linewidth" instead of "size" !!!
  default_aes = aes(
    width = 0.5, colour = "black", linewidth = 2, linetype = 1, # linewidth instead of size
    alpha = NA
  ),

[...]

Not sure this repo is still being updated, but others might find this info useful as well...

clauswilke commented 10 months ago

I don't really maintain this repo any longer. But you're welcome to submit a PR with this fix and I'll merge it.