| Title: | Making ggplot2 graphics in PRU style |
|---|---|
| Description: | A package to create graphics using ggplot2 styled by the PRU team. |
| Authors: | Androniki Stavrou [aut, cre] (ORCID: <https://orcid.org/0000-0003-4094-1019>), Enrico Spinielli [aut] (ORCID: <https://orcid.org/0000-0001-8584-9131>), EUROCONTROL [cph, fnd] |
| Maintainer: | Androniki Stavrou <[email protected]> |
| License: | GPL-2 |
| Version: | 0.1.0 |
| Built: | 2026-12-05 20:32:42 UTC |
| Source: | https://github.com/euctrl-pru/ectrlplot |
Running this function will add the Eurocontrol logo in your plot and save it to your specified location.
add_logo(plot_name, source_name, save_filepath = file.path(Sys.getenv("TMPDIR"), "tmp-nc.png"), width_pixels = 640, height_pixels = 450, logo_image_path = system.file("extdata", "euctrl-logo-wide.png", package = "ectrlplot"))add_logo(plot_name, source_name, save_filepath = file.path(Sys.getenv("TMPDIR"), "tmp-nc.png"), width_pixels = 640, height_pixels = 450, logo_image_path = system.file("extdata", "euctrl-logo-wide.png", package = "ectrlplot"))
plot_name |
The variable name of the plot you have created that you want to format and save |
source_name |
The text you want to come after the text 'Source:' in the bottom left hand side of your chart |
save_filepath |
The exact filepath that you want your plot to be saved to |
width_pixels |
Width in pixels that you want to save your chart to - defaults to 640 |
height_pixels |
Height in pixels that you want to save your chart to - defaults to 450 |
logo_image_path |
File path for the logo image you want to use in the right hand side of your chart, which needs to be a PNG file - defaults to Eurocontrol logo that sits within the extdata folder of your package |
library(ggplot2) myplot <- ggplot(mpg, aes(displ, hwy)) + geom_point() + theme_pru() + labs(title = 'Scatterplot example in ggplot2', subtitle = 'A plot that is only useful for demonstration purposes') add_logo(plot_name = myplot, source = "Source: The source of my data", width_pixels = 640, height_pixels = 450, save_filepath = "path-name.png") # If you want to use your own logo image, # change the path in the logo-image-path argument ## Not run: add_logo(plot_name = myplot, source = "Source: The source of my data", save_filepath = "path-name.png", width_pixels = 640, height_pixels = 450, logo_image_path = "use-your-logo-image-path") ## End(Not run)library(ggplot2) myplot <- ggplot(mpg, aes(displ, hwy)) + geom_point() + theme_pru() + labs(title = 'Scatterplot example in ggplot2', subtitle = 'A plot that is only useful for demonstration purposes') add_logo(plot_name = myplot, source = "Source: The source of my data", width_pixels = 640, height_pixels = 450, save_filepath = "path-name.png") # If you want to use your own logo image, # change the path in the logo-image-path argument ## Not run: add_logo(plot_name = myplot, source = "Source: The source of my data", save_filepath = "path-name.png", width_pixels = 640, height_pixels = 450, logo_image_path = "use-your-logo-image-path") ## End(Not run)
A diverging, colorblind safe color palette
pru_pal()pru_pal()
library(scales) show_col(pru_pal()(6))library(scales) show_col(pru_pal()(6))
See pru_pal.
scale_colour_pru(...) scale_color_pru(...) scale_fill_pru(...)scale_colour_pru(...) scale_color_pru(...) scale_fill_pru(...)
... |
Arguments passed on to
|
library(ggplot2) library(scales) g <- ggplot(mpg[1:48,], aes(displ, hwy, colour = class)) + geom_point() g + scale_color_pru() p <- ggplot(mpg[1:108,], aes(class)) + geom_bar(aes(fill = manufacturer)) p + scale_fill_pru()library(ggplot2) library(scales) g <- ggplot(mpg[1:48,], aes(displ, hwy, colour = class)) + geom_point() g + scale_color_pru() p <- ggplot(mpg[1:108,], aes(class)) + geom_bar(aes(fill = manufacturer)) p + scale_fill_pru()
This function allows you to add the pru theme to your ggplot graphics.
theme_pru()theme_pru()
library(ggplot2) p1 <- ggplot(mpg, aes(displ, hwy)) + geom_point() + labs(title = 'Scatterplot example in ggplot2', subtitle = 'A plot that is only useful for demonstration purposes') p1 + theme_pru() p2 <- ggplot(mpg[1:108,], aes(class)) + geom_bar(aes(fill = manufacturer)) + labs(title = 'Barplot example in ggplot2', subtitle = 'A plot that is only useful for demonstration purposes') p2 + theme_pru()library(ggplot2) p1 <- ggplot(mpg, aes(displ, hwy)) + geom_point() + labs(title = 'Scatterplot example in ggplot2', subtitle = 'A plot that is only useful for demonstration purposes') p1 + theme_pru() p2 <- ggplot(mpg[1:108,], aes(class)) + geom_bar(aes(fill = manufacturer)) + labs(title = 'Barplot example in ggplot2', subtitle = 'A plot that is only useful for demonstration purposes') p2 + theme_pru()