0

Just updated ggplot2 from 3.3.6 to 3.4.0. It has been documented that new version of ggplot2 replaced size with linewidth in geom_line() and geom_sf().

However, it appears that the new version does not get along well with rayshader package on my machine with Ubuntu 22.04.

ggplot2 3.3.6

library(tidyverse)
library(rayshader)
# df with geometry is not included
p <- df %>% ggplot() +
  geom_sf(aes(geometry = geometry, fill = value), color = "black", size = 0.25) +
  scale_fill_viridis_c(option = "C", limits = c(0, 100)) +
  coord_sf(xlim = c(100, 180), ylim = c(-60, -10)) +
  theme(legend.position = "none")
p
filename_movie <- tempfile()
plot_gg(p,
  zoom = 0.6,
  multicore = TRUE,
  raytrace = TRUE,
  phi = 30,
  theta = 0
)
render_snapshot(filename = "gr_1")
rgl::rgl.close()

enter image description here

The above is the expected graph.

ggplot2 3.4.0

I used the same code, only difference is that size = 0.25 was replaced by linewidth = 0.25. I got the following graph (obviously not correct). My current fix is to switch back to ggplot 3.3.6. It would be nice to use new ggplot2.

enter image description here

Zhiqiang Wang
  • 6,206
  • 2
  • 13
  • 27
  • 1
    Well, while `ggplot2 3.4.0` introduced the `linewidth` argument, `size` could still be used as otherwise all old code will break. Only drawback is that you get a warning. – stefan Nov 11 '22 at 09:02
  • True, either `linewidth` or `size` worked fine when generating 2D graph `p` but when transforming 2D into 3D using `rayshader`, it produced an incorrect 3D graph, as shown in OP. – Zhiqiang Wang Nov 11 '22 at 09:32
  • 1
    I had a look at the [changelog](https://ggplot2.tidyverse.org/news/index.html#breaking-changes-3-4-0) and it looks that `geom_sf` is a bit special: "For geoms that have both point sizing and linewidth sizing (geom_pointrange() and **geom_sf**) size now only refers to sizing of points which can leads to a visual change in old code". – stefan Nov 11 '22 at 09:45

0 Answers0