{"id":33187028,"url":"https://scotgovanalysis.github.io/sgplot/","last_synced_at":"2025-11-20T23:01:09.509Z","repository":{"id":65455375,"uuid":"590954898","full_name":"ScotGovAnalysis/sgplot","owner":"ScotGovAnalysis","description":"Graphic styles and colours for Scottish Government plots","archived":false,"fork":false,"pushed_at":"2025-08-07T11:21:20.000Z","size":8821,"stargazers_count":15,"open_issues_count":20,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-10-22T05:02:59.520Z","etag":null,"topics":["accessibility","colours","ggplot2","ggplot2-theme","r","r-package","rstats","style"],"latest_commit_sha":null,"homepage":"https://scotgovanalysis.github.io/sgplot/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ScotGovAnalysis.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-01-19T15:51:06.000Z","updated_at":"2025-10-08T11:22:31.000Z","dependencies_parsed_at":"2024-01-12T22:48:32.826Z","dependency_job_id":"476a69c7-70b2-4918-afd7-23c9c5620770","html_url":"https://github.com/ScotGovAnalysis/sgplot","commit_stats":null,"previous_names":["scotgovanalysis/sgplot"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/ScotGovAnalysis/sgplot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScotGovAnalysis%2Fsgplot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScotGovAnalysis%2Fsgplot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScotGovAnalysis%2Fsgplot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScotGovAnalysis%2Fsgplot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ScotGovAnalysis","download_url":"https://codeload.github.com/ScotGovAnalysis/sgplot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScotGovAnalysis%2Fsgplot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285526205,"owners_count":27186656,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-20T02:00:05.334Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["accessibility","colours","ggplot2","ggplot2-theme","r","r-package","rstats","style"],"created_at":"2025-11-16T05:00:30.369Z","updated_at":"2025-11-20T23:01:09.501Z","avatar_url":"https://github.com/ScotGovAnalysis.png","language":"R","funding_links":[],"categories":["Themes and aesthetics"],"sub_categories":[],"readme":"---\noutput: github_document\neditor_options: \n  chunk_output_type: console\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  warning = FALSE,\n  error = FALSE,\n  message = FALSE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  dev = \"svg\"\n)\n\nex1_alt \u003c- paste(\"A bar chart with grey background, white grid lines\",\n                 \"and dark grey bars.\")\nex2_alt \u003c- paste(\"A bar chart with white background,\",\n                 \"light grey horizontal grid lines dark blue bars.\")\n\n```\n\n# sgplot \u003cimg src=\"man/figures/logo.svg\" alt=\"sgplot logo\" align=\"right\" height=\"150\"/\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/sgplot)](https://CRAN.R-project.org/package=sgplot) \n[![R build status](https://github.com/ScotGovAnalysis/sgplot/workflows/R-CMD-check/badge.svg)](https://github.com/ScotGovAnalysis/sgplot/actions/workflows/R-CMD-check.yaml)\n\u003c!-- badges: end --\u003e\n\nsgplot is an R package for creating accessible plots in the Scottish Government. Currently, functions are available for styling ggplot2 plots.\n\nThe package has been developed using the [Government Analysis Function Data Visualisation guidance](https://analysisfunction.civilservice.gov.uk/policy-store/data-visualisation-charts/) and uses accessible colour palettes from the [Scottish Government Design System](https://designsystem.gov.scot/guidance/charts/data-visualisation-colour-palettes).\nsgplot should be used in conjunction with these guidance documents.\n\nMore information about the package and its functions can be found on the [sgplot website](https://ScotGovAnalysis.github.io/sgplot/). \nIn particular, the [cookbook](https://ScotGovAnalysis.github.io/sgplot/articles/cookbook.html) contains lots of examples. \nSlides are also available for an internal [presentation given to statisticians and analysts](https://alice-hannah.github.io/presentations-and-blogs/2023-06-19_sgplot/slides.html).\n\n\n## Installation\n\nIf you are working within the Scottish Government network, you can install sgplot in the same way as with other R packages.\n\nAlternatively, install from CRAN:\n\n``` r\ninstall.packages(\"sgplot\")\n```\n\nOr install the development version from GitHub:\n\n``` r\n# install.packages(\"remotes\")\nremotes::install_github(\n  \"ScotGovAnalysis/sgplot\",\n  upgrade = \"never\",\n  build_vignettes = TRUE\n)\n```\n\n\n## Getting Started\n\nOnce installed, sgplot can be loaded using the `library()` function:\n\n``` r\nlibrary(sgplot)\n```\n\nHelp files for each function in the package can be found on the [References](https://ScotGovAnalysis.github.io/sgplot/reference/) page of the package website. Alternatively, type `?function_name` into the RStudio console. For example:\n\n``` r\n?theme_sg()\n```\n\n\n### Use sgplot as default\n\nThe easiest way to use sgplot is by adding `use_sgplot()` to the beginning of your R script, Rmarkdown document or Shiny app code. This function will set a number of defaults to ggplot2 geoms, use sgplot colour palettes and use `theme_sg()`. \n\n#### Example 1: Plot with one colour using ggplot2 defaults\n\n```{r ex1, fig.alt = ex1_alt}\nlibrary(ggplot2)\nlibrary(dplyr)\nlibrary(gapminder)\n\ngapminder |\u003e \n  filter(year == 2007 \u0026 continent == \"Europe\") |\u003e\n  slice_max(order_by = lifeExp, n = 5) |\u003e\n  ggplot() +\n  geom_col(aes(x = reorder(country, -lifeExp), y = lifeExp)) +\n  scale_y_continuous(expand = c(0, 0)) +\n  labs(\n    x = NULL,\n    y = NULL,\n    title = \"Iceland has the highest life expectancy in Europe\",\n    subtitle = \"Life expectancy in European countries, 2007\",\n    caption = \"Source: Gapminder\"\n  )\n```\n\n#### Example 2: Plot with one colour using sgplot defaults\n\n```{r ex2, fig.alt = ex2_alt}\nsgplot::use_sgplot()\n\ngapminder |\u003e \n  filter(year == 2007 \u0026 continent == \"Europe\") |\u003e\n  slice_max(order_by = lifeExp, n = 5) |\u003e\n  ggplot() +\n  geom_col(aes(x = reorder(country, -lifeExp), y = lifeExp)) +\n  scale_y_continuous(expand = c(0, 0)) +\n  labs(\n    x = NULL,\n    y = NULL,\n    title = \"Iceland has the highest life expectancy in Europe\",\n    subtitle = \"Life expectancy in European countries, 2007\",\n    caption = \"Source: Gapminder\"\n  )\n```\n\n**Note on use of titles, subtitles and captions** \u003cbr\u003e\nTitles, subtitles and captions have been embedded in these example charts for demonstration purposes. However, for accessibility reasons, it is usually preferable to provide titles in the body of the page rather than embedded within the image of the plot. More information is available in the [accessibility article](https://ScotGovAnalysis.github.io/sgplot/articles/accessibility.html#other-accessibility-considerations).\n\n## Licence\n\nUnless stated otherwise, the codebase is released under [the MIT License](LICENSE). This covers both the codebase and any sample code in the documentation.\n\nThe documentation is [© Crown copyright](https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/) and available under the terms\nof the [Open Government 3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/) licence.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/scotgovanalysis.github.io%2Fsgplot%2F","html_url":"https://awesome.ecosyste.ms/projects/scotgovanalysis.github.io%2Fsgplot%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/scotgovanalysis.github.io%2Fsgplot%2F/lists"}