Public-Health-Scotland / phsstyles

Standard Graphic Styles for use in Public Health Scotland (https://public-health-scotland.github.io/phsstyles/)
https://public-health-scotland.github.io/phsstyles/
Other
14 stars 1 forks source link

theme_phs() automatically strips axis titles #3

Closed RosalynLP closed 2 years ago

RosalynLP commented 2 years ago

I've noticed that using theme_phs() seems to delete any axis titles you provide, which doesn't seem ideal to me - is this PHS policy to have no axis titles / is there an easy way to circumvent this behaviour?

Basic example:

## Using theme_phs()

library(phsstyles)
library(tidyr)

# Create test data
a <- 1:10
t <- tibble(a, b = a **2)

# Output 1
t %>% ggplot(aes(x=a, y=b)) +
  geom_point() +
  labs(x="x label", y="y label")

# Output 2
t %>% ggplot(aes(x=a, y=b)) +
  geom_point() +
  labs(x="x label", y="y label") +
  theme_phs()

Where Output 1 is image

and Output 2 is image

despite the fact x and y labels are specified.

I'm guessing this is because in theme_phs() axis.titleis set to element_blank()?

EDIT: I made a local branch (don't have permissions to link to origin) and tried setting axis.title as element_text() but this didn't solve the issue. I am guessing somehow I have to set the x label to the axis.text parameter but I'm not sure how to do this. Regardless I think it'd be good if the theme didn't wipe axis labels that are there to begin with.

Tina815 commented 2 years ago

I have updated the function and it won't make the axis title blank.