Title: | Add Ipea Editorial Standards to 'ggplot2' Graphics |
---|---|
Description: | Convenient functions to create 'ggplot2' graphics following the editorial guidelines of the Institute for Applied Economic Research (Ipea). |
Authors: | Pedro Ferreira [aut, cre], Pedro Jorge [aut], Daniel Lima [aut], Gustavo Coelho [aut], Rafael H. M. Pereira [aut], Lucas Mation [aut], Fabio Vaz [ctb], Ipea - Institue for Applied Economic Research [cph, fnd] |
Maintainer: | Pedro Ferreira <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.1.9000 |
Built: | 2025-02-26 16:26:37 UTC |
Source: | https://github.com/ipeadata-lab/ipeaplot |
Ipea palette
ipea_pal( palette = c("Blue", "Green", "Orange", "Pink", "Green-Blue", "Green-Blue-White", "Red-Blue", "Red-Blue-White", "Orange-Blue", "Orange-Blue-White", "Viridis", "Inferno", "Magma", "Plasma", "Cividis"), alpha = 1, begin = 0, end = 1, palette_direction = 1 )
ipea_pal( palette = c("Blue", "Green", "Orange", "Pink", "Green-Blue", "Green-Blue-White", "Red-Blue", "Red-Blue-White", "Orange-Blue", "Orange-Blue-White", "Viridis", "Inferno", "Magma", "Plasma", "Cividis"), alpha = 1, begin = 0, end = 1, palette_direction = 1 )
palette |
A character string indicating the color map option to use. These options are available: 'Blue', 'Green', 'Orange', 'Pink', 'Red-Blue' 'Orange-Blue', 'Green-Blue', 'Viridis', 'Inferno', 'Magma', 'Plasma' 'Cividis'. |
alpha |
The alpha transparency in a number between |
begin |
The (corrected) hue in a number between |
end |
The (corrected) hue in a number between |
palette_direction |
Sets the order of colors in the scale. If 1, the default, colors are ordered from darkest to lightest. If -1, the order of colors is reversed. |
ipea_palette
produces a character vector, cv
, containing color hex codes.
This vector can be utilized to establish a custom color scheme for future graphics using palette(cv)
,
or it can be applied directly as a col =
parameter in graphic functions or within par
.
'Blue','Green','Orange','Pink','Green-Blue','Green-Blue-White','Red-Blue','Red-Blue-White', 'Orange-Blue','Orange-Blue-White', 'Viridis','Inferno', 'Magma','Plasma' and 'Cividis': https://pmassicotte.github.io/paletteer_gallery/
scales::show_col(ipea_pal()(10)) scales::show_col(ipea_pal(palette_direction = -1)(6)) scales::show_col(ipea_pal(begin = 0.2, end = 0.8)(4)) scales::show_col(ipea_pal(palette = "Green")(6))
scales::show_col(ipea_pal()(10)) scales::show_col(ipea_pal(palette_direction = -1)(6)) scales::show_col(ipea_pal(begin = 0.2, end = 0.8)(4)) scales::show_col(ipea_pal(palette = "Green")(6))
This function creates a vector of n equally spaced colors along the selected color map.
ipea_palette( palette = c("Blue", "Green", "Orange", "Pink", "Green-Blue", "Green-Blue-White", "Red-Blue", "Red-Blue-White", "Orange-Blue", "Orange-Blue-White", "Viridis", "Inferno", "Magma", "Plasma", "Cividis"), n, alpha = 1, begin = 0, end = 1, palette_direction = 1 )
ipea_palette( palette = c("Blue", "Green", "Orange", "Pink", "Green-Blue", "Green-Blue-White", "Red-Blue", "Red-Blue-White", "Orange-Blue", "Orange-Blue-White", "Viridis", "Inferno", "Magma", "Plasma", "Cividis"), n, alpha = 1, begin = 0, end = 1, palette_direction = 1 )
palette |
A character string indicating the color map option to use. These options are available:'Blue', 'Green', 'Orange', 'Pink', 'Red-Blue' 'Orange-Blue', 'Green-Blue', 'Red-Blue-White', 'Orange-Blue-White', 'Green-Blue-White', 'Viridis', 'Inferno', 'Magma', 'Plasma', 'Cividis'. |
n |
The number of colors ( |
alpha |
The alpha transparency in a number between |
begin |
The (corrected) hue in a number between |
end |
The (corrected) hue in a number between |
palette_direction |
Sets the order of colors in the scale. If |
A 9-color Ipea palette.
ipea_palette
produces a character vector, cv
, containing color hex codes.
This vector can be utilized to establish a custom color scheme for future graphics using palette(cv)
,
or it can be applied directly as a col =
parameter in graphic functions or within par
.
'Blue','Green','Orange','Pink','Green-Blue','Green-Blue-White','Red-Blue','Red-Blue-White', 'Orange-Blue','Orange-Blue-White', 'Viridis','Inferno', 'Magma','Plasma' and 'Cividis': https://pmassicotte.github.io/paletteer_gallery/
Convenient functions to create ggplot graphics following the editorial guidelines of the Institute for Applied Economic Research - Ipea.
Please check the vignettes and data documentation on the website.
Maintainer: Pedro Ferreira [email protected]
Authors:
Pedro Jorge [email protected]
Daniel Lima [email protected]
Gustavo Coelho [email protected]
Rafael H. M. Pereira [email protected]
Lucas Mation [email protected]
Other contributors:
Fabio Vaz [email protected] [contributor]
Ipea - Institue for Applied Economic Research [copyright holder, funder]
Useful links:
Report bugs at https://github.com/ipeadata-lab/ipeaplot/issues
Convenient function to save charts in Eps format.
save_eps(gplot, file.name, ...)
save_eps(gplot, file.name, ...)
gplot |
ggplot which will be saved. |
file.name |
Character. Name of the file which will be generated |
... |
Additional arguments to be passed to the |
An "eps"
file
Other save:
save_pdf()
# Creating theme for ggplot2 graph using default arguments library(ggplot2) fig_raw <- ggplot() + geom_col(data = mtcars, aes(x = hp , y = mpg, fill = cyl)) + theme_ipea() # Save ggplot output save_eps(fig_raw,file.name = paste0(tempdir(),"/figura.eps"))
# Creating theme for ggplot2 graph using default arguments library(ggplot2) fig_raw <- ggplot() + geom_col(data = mtcars, aes(x = hp , y = mpg, fill = cyl)) + theme_ipea() # Save ggplot output save_eps(fig_raw,file.name = paste0(tempdir(),"/figura.eps"))
Convenient function to save charts in PDF format.
save_pdf(gplot, file.name, ...)
save_pdf(gplot, file.name, ...)
gplot |
ggplot which will be saved. |
file.name |
Character. Name of the file which will be generated |
... |
Additional arguments to be passed to the |
An "PDF"
file
Other save:
save_eps()
# Creating theme for ggplot2 graph using default arguments library(ggplot2) fig_raw <- ggplot() + geom_col(data = mtcars, aes(x = hp , y = mpg, fill = cyl)) + theme_ipea() # Save ggplot output save_pdf(fig_raw,file.name = paste0(tempdir(),"/figura.pdf"))
# Creating theme for ggplot2 graph using default arguments library(ggplot2) fig_raw <- ggplot() + geom_col(data = mtcars, aes(x = hp , y = mpg, fill = cyl)) + theme_ipea() # Save ggplot output save_pdf(fig_raw,file.name = paste0(tempdir(),"/figura.pdf"))
Generate a color palette (continuous or discrete) following the editorial guidelines used by the Institute for Applied Economic Research - Ipea.
scale_color_ipea( palette = c("Blue", "Green", "Orange", "Pink", "Green-Blue", "Green-Blue-White", "Red-Blue", "Red-Blue-White", "Orange-Blue", "Orange-Blue-White", "Viridis", "Inferno", "Magma", "Plasma", "Cividis"), palette_direction = 1, decimal.mark = ",", barheight = NULL, barwidth = NULL, title.hjust = NULL, label.hjust = NULL, ... )
scale_color_ipea( palette = c("Blue", "Green", "Orange", "Pink", "Green-Blue", "Green-Blue-White", "Red-Blue", "Red-Blue-White", "Orange-Blue", "Orange-Blue-White", "Viridis", "Inferno", "Magma", "Plasma", "Cividis"), palette_direction = 1, decimal.mark = ",", barheight = NULL, barwidth = NULL, title.hjust = NULL, label.hjust = NULL, ... )
palette |
A character vector specifying the available palette for the
color palette. The default palette are |
palette_direction |
A logical argument specifying if the ordering of the colors will follow the default of the palette (when the argument is 1) or if it will have an inverted ordering (for cases where it is -1). |
decimal.mark |
The character to be used to indicate the numeric decimal point and
Character used between every 3 digits to separate thousands.
By default, the function uses a comma |
barheight |
The height of the color gradient bar. This parameter is used when the direction is set to "horizontal". |
barwidth |
The width of the color gradient bar. This parameter is used when the direction is set to "horizontal". |
title.hjust |
A number specifying horizontal justification of the title text. |
label.hjust |
A number specifying vertical justification of the title text. |
... |
Additional arguments to be passed to the scale_fill_gradientn, scale_color_gradientn, scale_fill_distiller or scale_color_distiller function from the ggplot2 package. |
A list object be added to a ggplot object to change color pallete.
Other ggplot2 theme functions:
scale_fill_ipea()
,
theme_ipea()
# Creating scale for ggplot2 graph using default arguments library(ggplot2) fig_raw <- ggplot() + geom_point(data = mtcars, aes(x = hp , y = mpg, color = cyl)) + scale_color_ipea() # Creating scale for ggplot2 graph using green sequential palette fig_raw <- ggplot() + geom_point(data = mtcars, aes(x = hp , y = mpg, color = cyl)) + scale_color_ipea(palette = "Green")
# Creating scale for ggplot2 graph using default arguments library(ggplot2) fig_raw <- ggplot() + geom_point(data = mtcars, aes(x = hp , y = mpg, color = cyl)) + scale_color_ipea() # Creating scale for ggplot2 graph using green sequential palette fig_raw <- ggplot() + geom_point(data = mtcars, aes(x = hp , y = mpg, color = cyl)) + scale_color_ipea(palette = "Green")
Generate a fill palette (continuous or discrete) in the formatting of texts published by the Institute for Applied Economic Research (IPEA)
scale_fill_ipea( palette = c("Blue", "Green", "Orange", "Pink", "Green-Blue", "Green-Blue-White", "Red-Blue", "Red-Blue-White", "Orange-Blue", "Orange-Blue-White", "Viridis", "Inferno", "Magma", "Plasma", "Cividis"), palette_direction = 1, decimal.mark = ",", barheight = NULL, barwidth = NULL, title.hjust = NULL, label.hjust = NULL, ... )
scale_fill_ipea( palette = c("Blue", "Green", "Orange", "Pink", "Green-Blue", "Green-Blue-White", "Red-Blue", "Red-Blue-White", "Orange-Blue", "Orange-Blue-White", "Viridis", "Inferno", "Magma", "Plasma", "Cividis"), palette_direction = 1, decimal.mark = ",", barheight = NULL, barwidth = NULL, title.hjust = NULL, label.hjust = NULL, ... )
palette |
A character vector specifying the available palette for the
color palette. The default palette are |
palette_direction |
A logical argument specifying if the ordering of the colors will follow the default of the palette (when the argument is 1) or if it will have an inverted ordering (for cases where it is 0). |
decimal.mark |
The character to be used to indicate the numeric decimal point and
Character used between every 3 digits to separate thousands.
By default, the function uses a comma |
barheight |
The height of the color gradient bar. This parameter is used when the direction is set to "horizontal". |
barwidth |
The width of the color gradient bar. This parameter is used when the direction is set to "horizontal". |
title.hjust |
A number specifying horizontal justification of the title text. |
label.hjust |
A number specifying vertical justification of the title text. |
... |
Additional arguments to be passed to the scale_fill_gradientn, scale_color_gradientn, scale_fill_distiller or scale_color_distiller function from the ggplot2 package |
A list object be added to a ggplot object to change color pallete.
Other ggplot2 theme functions:
scale_color_ipea()
,
theme_ipea()
# Creating scale for ggplot2 graph using default arguments library(ggplot2) fig_raw <- ggplot() + geom_col(data = mtcars, aes(x = hp , y = mpg, fill = cyl)) + scale_fill_ipea() # Creating scale for ggplot2 graph using green sequential palette fig_raw <- ggplot() + geom_col(data = mtcars, aes(x = hp , y = mpg, fill = cyl)) + scale_fill_ipea(palette = "Green")
# Creating scale for ggplot2 graph using default arguments library(ggplot2) fig_raw <- ggplot() + geom_col(data = mtcars, aes(x = hp , y = mpg, fill = cyl)) + scale_fill_ipea() # Creating scale for ggplot2 graph using green sequential palette fig_raw <- ggplot() + geom_col(data = mtcars, aes(x = hp , y = mpg, fill = cyl)) + scale_fill_ipea(palette = "Green")
Applies a custom theme for ggplot figures following the editorial guidelines used by the Institute for Applied Economic Research - Ipea. The function includes standardized formatting of options for axis lines, text,
theme_ipea( axis_lines = "full", axis_values = TRUE, legend.position = "right", grid.adjust = "horizontal", x_breaks = NULL, y_breaks = NULL, expand_x_limit = TRUE, expand_y_limit = TRUE, x_text_angle = 0, include_x_text_title = TRUE, include_y_text_title = TRUE, include_ticks = TRUE, ... )
theme_ipea( axis_lines = "full", axis_values = TRUE, legend.position = "right", grid.adjust = "horizontal", x_breaks = NULL, y_breaks = NULL, expand_x_limit = TRUE, expand_y_limit = TRUE, x_text_angle = 0, include_x_text_title = TRUE, include_y_text_title = TRUE, include_ticks = TRUE, ... )
axis_lines |
A character vector specifying the axis style. Valid options are
|
axis_values |
Logical value indicating whether to show text elements. If |
legend.position |
A character vector specifying the position of the
legend. Valid options are |
grid.adjust |
Defines whether the grid lines should be |
x_breaks |
Numeric. The number of breaks on the x-axis |
y_breaks |
Numeric. The number of breaks on the y-axis |
expand_x_limit |
Logical value that indicates whether the x-axis
boundary should be expanded. If |
expand_y_limit |
Logical value that indicates whether the y-axis
boundary should be expanded. If |
x_text_angle |
Numeric. Angle in degrees of the text in the x-axis. |
include_x_text_title |
Logical. Whether to include x text title Defaults to |
include_y_text_title |
Logical. Whether to include x text title. Defaults to |
include_ticks |
Logical. Whether to include ticks. Defaults to |
... |
Additional arguments to be passed to the |
A custom theme for IPEA graphics.
Other ggplot2 theme functions:
scale_color_ipea()
,
scale_fill_ipea()
# Creating theme for ggplot2 graph using default arguments library(ggplot2) fig_raw <- ggplot() + geom_col(data = mtcars, aes(x = hp , y = mpg, fill = cyl)) + theme_ipea()
# Creating theme for ggplot2 graph using default arguments library(ggplot2) fig_raw <- ggplot() + geom_col(data = mtcars, aes(x = hp , y = mpg, fill = cyl)) + theme_ipea()