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

Using phsstyles without the need to load phsstyles #9

Open Nic-Chr opened 2 months ago

Nic-Chr commented 2 months ago

Hi, some functions are not working unless phsstyles is loaded, e.g. via library(). This is problematic for developers that wish to import phsstyles into their own package or simply use the functions without needing to load the package.

I notice that this issue has been raised before here: #1

Below is an example of how this problem manifests.

library(tidyverse)
iris |> 
  ggplot(aes(x = Sepal.Length, y = Sepal.Width)) + 
  geom_point(aes(col = Species)) + 
  phsstyles::scale_colour_discrete_phs()
#> Error in name %in% phs_palette_types[["seq"]]: object 'phs_palette_types' not found
  library(phsstyles)
iris |> 
  ggplot(aes(x = Sepal.Length, y = Sepal.Width)) + 
  geom_point(aes(col = Species)) + 
  phsstyles::scale_colour_discrete_phs()

Created on 2024-05-13 with reprex v2.0.2

Nic-Chr commented 2 months ago

I have written up a working fix to address this issue and I'd be happy to open a pull request.