corybrunson / ggalluvial

ggplot2 extension for alluvial plots
http://corybrunson.github.io/ggalluvial/
GNU General Public License v3.0
499 stars 34 forks source link

Bug with legend.position with R 4.1 graphics engine #90

Closed qdread closed 1 year ago

qdread commented 3 years ago

Hey Cory, I think I came across an issue while testing the new xspline code. I had to update to R 4.1.x to test with the new graphics engine. I noticed that although the package versions of ggalluvial (0.12.3) and ggplot2 (3.3.5) are the same between the two R versions (R 4.0.3 and R 4.1.1) I get different behavior of between the two versions. I noticed this because I cannot recreate the UCB admissions plot from the Shiny vignette.

Oddly enough, when I have the scale expansion set to the way I want it, when you add theme(legend.position = 'bottom') to the plot, the alluvia polygons disappear! I have no idea why this is, and it only appears in R 4.1.1 not 4.0.3.

Here's the reprex. What the heck is going on??? 😕

library(ggalluvial)
#> Loading required package: ggplot2
data(UCBAdmissions)
ucb_admissions <- as.data.frame(UCBAdmissions)

p <- ggplot(ucb_admissions,
       aes(y = Freq, axis1 = Gender, axis2 = Dept)) + 
  geom_alluvium(aes(fill = Admit), knot.pos = 1/4, width = 1/3) + 
  geom_stratum(width = 1/4, reverse = TRUE, fill = 'black', color = 'grey') + 
  scale_x_discrete(limits = c("Gender", "Dept"), expand = c(.05, .05)) 

p

p + theme(legend.position = "bottom")

Created on 2021-08-19 by the reprex package (v2.0.1)

qdread commented 3 years ago

I'm trying to create a reprex that doesn't involve ggalluvial, only ggplot2, so that I can submit a bug report to ggplot2 directly, but I haven't been able to replicate the problem using only ggplot2 functions.

corybrunson commented 3 years ago

I'm on a Mac, and the ribbons still appeared with R 4.0.4 installed.

I just updated R to 4.1.1 and got the following alert:

R graphics engine version 14 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed.

When i run the code again, plots indeed came up in a separate window rather than in the tab, but both plots rendered just fine.

qdread commented 3 years ago

Hm, that's weird. I tried running it outside Rstudio in the RGui and still had the issue where the plot with legend.position='bottom' does not show the ribbons. All this is on Windows 10, R 4.1.1

corybrunson commented 3 years ago

Any updates on this front @qdread? I'm hoping to prepare v0.12.4 in the next week or two...finally. : \

corybrunson commented 1 year ago

Hopefully this issue is resolved! Please reopen it if the issue persists.