haleyjeppson/ggmosaic

Can't change axis labels with `labs`

Closed this issue · 2 comments

Axis labels can't be changed with labs in 0.2.2. Reprexes below are from #41 (comment). I separately verified that the issue also occurs with ggplot2 3.2.1, so I presume it arises from changes in ggmosaic.

Leaving ggplot2 constant at 3.3.0 I tried to make the reprexes as systematic as possible

ggmosaic = 0.2.0 from CRAN labels YES, tick marks NO

library(ggplot2)
library(ggmosaic)
packageDescription("ggmosaic")$Version
#> [1] "0.2.0"
packageDescription("ggplot2")$Version
#> [1] "3.3.0"

data(Titanic)
titanic <- as.data.frame(Titanic)
titanic$Survived <- factor(titanic$Survived, 
                           levels = c("Yes", "No"))

ggplot(data = titanic) +
  geom_mosaic(aes(weight = Freq, x = product(Class), fill = Survived)) +
# good practice: use the 'dependent' variable (or most important variable)
# as fill variable
  labs(x = "Passenger class", 
       y = "Survived sinking",
       title = "Survival rate by passenger class")

Created on 2020-03-24 by the reprex package (v0.3.0)

ggmosaic = 0.2.2 from GitHub master labels NO, tick marks NO

library(ggplot2)
library(ggmosaic)
packageDescription("ggmosaic")$Version
#> [1] "0.2.2"
packageDescription("ggplot2")$Version
#> [1] "3.3.0"

data(Titanic)
titanic <- as.data.frame(Titanic)
titanic$Survived <- factor(titanic$Survived, 
                           levels = c("Yes", "No"))

ggplot(data = titanic) +
  geom_mosaic(aes(weight = Freq, x = product(Class), fill = Survived)) +
# good practice: use the 'dependent' variable (or most important variable)
# as fill variable
  labs(x = "Passenger class", 
       y = "Survived sinking",
       title = "Survival rate by passenger class")

Created on 2020-03-24 by the reprex package (v0.3.0)

ggmosaic = 0.2.2-hotfix from GitHub _ x and y labels NO, tick marks YES_

library(ggplot2)
library(ggmosaic)
# devtools::install_github('rmcd1024/ggmosaic', ref="ggplot_3.3.0-scales/fix")
packageDescription("ggmosaic")$Version
#> [1] "0.2.2"
packageDescription("ggmosaic")$RemoteRef
#> [1] "ggplot_3.3.0-scales/fix"
packageDescription("ggplot2")$Version
#> [1] "3.3.0"

data(Titanic)
titanic <- as.data.frame(Titanic)
titanic$Survived <- factor(titanic$Survived, 
                           levels = c("Yes", "No"))

ggplot(data = titanic) +
  geom_mosaic(aes(weight = Freq, x = product(Class), fill = Survived)) +
# good practice: use the 'dependent' variable (or most important variable)
# as fill variable
  labs(x = "Passenger class", 
       y = "Survived sinking",
       title = "Survival rate by passenger class")

Created on 2020-03-24 by the reprex package (v0.3.0)

Originally posted by @ibecav in #41 (comment)

I believe this is fixed now and I've created the table below to summarise the compatibility issues.

ggmosaic ggplot2 axis labels tick labels
3.3.0 (CRAN) 0.3.0
3.3.0 (CRAN) 0.2.2 defaults okay, must use scale_*_productlist() to modify Do not show up
3.2.1 0.2.2 defaults okay, must use scale_*_productlist() to modify
3.2.1 0.2.0 (CRAN) defaults are wrong, but can use labs() to modify

Thank you. My CRAN mirror doesn't have 0.3.0 yet but I can confirm that after updating from the github repository the problem I noted is fixed. Thank you!