No axis tick marks and axis tick mark labels with ggmosaic

Hi everyone,

I am trying to create a spineplot with ggmosaic. However, axis tick marks and labels do not show up. I also tried to add them manually with scale_x_productlist().

According to the following discussion, there had been a compartibility problem with different ggplot2 and ggmosaic versions: https://github.com/haleyjeppson/ggmosaic/issues/41.
Unfortunately, it seems like the problem still occurs with ggmosaic 0.2.0 and ggplot2 3.3.2.

Changing the axis label is possible.

I would highly appreciate any advice! Thanks!

library(tidyverse)
library(ggplot2)
library(ggmosaic)
library(haven)
library(titanic)


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

titanic <- titanic::titanic_train

titanic <- titanic %>% 
  mutate(
    survived = factor(Survived, labels = c("Died", "Survived")),
    pclass = factor(Pclass)
  )

ggplot(data = titanic) +
  geom_mosaic(aes(x = product(pclass), fill = survived))

ggplot(data = titanic) +
  geom_mosaic(aes(x = product(survived,pclass), fill = survived)) +
  ggplot2::labs(x = "Passenger class",
                y = "Survived sinking",
                title = "Survival rate by passenger class")

ggplot(data = titanic) +
  geom_mosaic(aes(x = product(survived,pclass), fill = survived)) +
  ggplot2::labs(x = "Passenger class",
                y = "Survived sinking",
                title = "Survival rate by passenger class") +
  scale_x_productlist(name="Risk Perception",breaks=c(1:3), labels=c("class1", "class2", "class3"))

Created on 2020-09-18 by the reprex package (v0.3.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.