Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Greater-London-Authority/gglaplot
Makes graphics in the GLA style using ggplot2
https://github.com/Greater-London-Authority/gglaplot
ggplot2 r visualization
Last synced: 3 months ago
JSON representation
Makes graphics in the GLA style using ggplot2
- Host: GitHub
- URL: https://github.com/Greater-London-Authority/gglaplot
- Owner: Greater-London-Authority
- Created: 2019-01-14T12:28:38.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-09-08T11:02:37.000Z (about 1 year ago)
- Last Synced: 2024-07-17T06:44:14.086Z (4 months ago)
- Topics: ggplot2, r, visualization
- Language: R
- Homepage: https://greater-london-authority.github.io/gglaplot/
- Size: 6.56 MB
- Stars: 17
- Watchers: 2
- Forks: 7
- Open Issues: 8
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
---
output: github_document
---```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.path = "man/figures/")
```# gglaplot
The package provides several wrappers and tools to use with ggplot2 and plotly to make graphics that follow the GLA [City Intelligence Data Design Guidelines](https://data.london.gov.uk/blog/city-intelligence-data-design-guidelines/).
## Installation
```{r Installation, eval=FALSE}
# To install from github use the devtools function:
# This will install all required dependencies
devtools::install_github("Greater-London-Authority/gglaplot")
```## Usage
```{r Usage, message=FALSE, warning=FALSE, dpi = 300}
library(ggplot2)
library(gglaplot)
library(dplyr)
library(scales)
library(lubridate)pal <- gla_pal(gla_theme = "default", palette_type = "highlight", n = c(1, 1))
theme_set(theme_gla(gla_theme = "default"))plot <- ggplot(data = LDNUK, mapping = aes(x = Year, y = GPG, group = location,
colour = location)) +
ggla_line(aes(size = location)) +
scale_size_manual(values = c(4 * mm_to_pt, 2 * mm_to_pt)) +
scale_colour_manual(values = pal) +
ggla_highlight(filter_type = "end") +
ggla_axisat0() +
scale_y_continuous(expand = c(0, 0), limits = c(0, 32.5),
labels = dollar_format(prefix = "", suffix = "%")) +
scale_x_date(date_breaks = "1 year", date_labels = "'%y",
expand = expansion(mult = c(0.05, 0.01))) +
labs(title = "Gender Pay Gap - Total (Median)",
subtitle = "Gender Pay Gap - Total (Median) - London VS UK",
caption = "Note: 2017 data is provisional\nChart: GLA City Intelligence Source: London Datastore")
plot
```Plots can be incorporated in Rmarkdown/Notebooks or exported to be included in documents/slideshows etc
```{r saving plot, message=FALSE, warning=FALSE, eval=FALSE}
ggsave(plot = plot, path = "example_plot.svg")
````.svg` is the best format to export plots, and the size and dpi of the output can be adjusted within `ggsave()`.
## Getting Help
### ggplot2
There are many online resources for ggplot2, including:
* [ggplot2 cheatsheet](https://ggplot2.tidyverse.org/)
* [ggplot2 documentation](https://ggplot2.tidyverse.org/reference/)
* [DataCamp course](https://www.datacamp.com/courses/data-visualization-with-ggplot2-1)### plotly
* [plotly website](https://plotly.com/r/)
* [plotly bookdown](https://plotly-r.com/)### gglaplot
For help with gglaplot itself, see the vignettes which are available on the [gglaplot github pages](https://greater-london-authority.github.io/gglaplot/).
The BBC has a similar package for their house style which has some comprehensive help pages [here](https://bbc.github.io/rcookbook/).