Title: | Additional theme and utilities for "ggplot2" in the Urban Institute style |
---|---|
Description: | Align "ggplot2" output more closely with the Urban Institute Data Visualization style guide <https://urbaninstitute.github.io/r-at-urban/graphics-guide.html>. |
Authors: | Aaron R. Williams [aut, cre], Kyle Ueyama [aut], Ajjit Narayanan [aut], Ben Chartoff [aut] |
Maintainer: | Aaron R. Williams <[email protected]> |
License: | GPL-3 |
Version: | 0.0.2 |
Built: | 2024-11-03 04:05:39 UTC |
Source: | https://github.com/UrbanInstitute/urbnthemes |
Adds tick axes and axes labels
add_axis(axis = "y")
add_axis(axis = "y")
axis |
Axis to drop. "x", "y", or "both" |
fontawesome_install
tests to see if FontAwesome is imported and registered. If FontAwesome, isn't imported and registered, then fontawesome_install
imports and registers FontAwesome with library(extrafont).
fontawesome_install()
fontawesome_install()
Note: FontAwesome must be installed on your computer for fontawesome_install
to work.
Test to see if FontAwesome is imported and registered with fontawesome_test()
.
fontawesome_test
tests to see if FontAwesome is imported and registered. FontAwesome is used for glyphs with library(waffle)
and can be installed from Bob Rudis's GitHub.
fontawesome_test()
fontawesome_test()
Import and register FontAwesome in R with fontawesome_install().
Submit ?ggplot2::geom_line
to see the full documentation for geom_bar()
geom_bar(mapping = NULL, width = 0.7, ...)
geom_bar(mapping = NULL, width = 0.7, ...)
mapping |
mapping from ggplot2 |
width |
bar width |
... |
other arguments passed to |
Submit ?ggplot2::geom_line
to see the full documentation for geom_col()
geom_col(mapping = NULL, width = 0.7, ...)
geom_col(mapping = NULL, width = 0.7, ...)
mapping |
mapping from ggplot2 |
width |
column width |
... |
other arguments passed to |
Extract just the legend from a ggplot2 object.
get_legend(ggplot_object)
get_legend(ggplot_object)
ggplot_object |
a ggplot |
a ggplot legend
lato_import()
tests to see if Lato is imported and registered. If
Lato, isn't imported and registered, then lato_import()
imports and
registers Lato with
library(extrafont).
lato_import()
lato_import()
Note: Lato must be installed on your computer for lato_import()
to
work. Lato is the Urban Institute's main font. To install, visit
Google fonts and click
"Download family". Unzip and open each of the .ttf files and click install.
Test to see if Lato is imported and registered with lato_test()
.
lato_install()
was deprecated because its name was ambiguous. Please use lato_import()
.
lato_install()
lato_install()
lato_test
tests to see if Lato is imported and registered. Lato is
the Urban Institute's main font and can be installed from
Google fonts.
lato_test()
lato_test()
Import and register Lato in R with lato_install().
Palette data for the Urban Institute
palette_urbn
palette_urbn
A list
.
Data used by the palettes in the uithemes package.
Vectors with hex-color codes that correspond to the color palettes outlined in the Urban Institute Data Visualization Style Guide. http://urbaninstitute.github.io/graphics-styleguide/
palette_urbn_main palette_urbn_diverging palette_urbn_quintile palette_urbn_politics palette_urbn_cyan palette_urbn_gray palette_urbn_yellow palette_urbn_magenta palette_urbn_green palette_urbn_spacegray palette_urbn_red
palette_urbn_main palette_urbn_diverging palette_urbn_quintile palette_urbn_politics palette_urbn_cyan palette_urbn_gray palette_urbn_yellow palette_urbn_magenta palette_urbn_green palette_urbn_spacegray palette_urbn_red
An object of class character
of length 8.
An object of class character
of length 8.
An object of class character
of length 5.
An object of class character
of length 2.
An object of class character
of length 8.
An object of class character
of length 8.
An object of class character
of length 8.
An object of class character
of length 8.
An object of class character
of length 8.
An object of class character
of length 8.
An object of class character
of length 8.
Urban Institute Data Visualization Style Guide http://urbaninstitute.github.io/graphics-styleguide/
Removes axes and axes labels
remove_axis(axis = "y", flip = FALSE)
remove_axis(axis = "y", flip = FALSE)
axis |
Axis to drop. "x", "y", or "both" |
flip |
TRUE/FALSE is |
Remove just the legend from a ggplot2 object.
remove_legend(ggplot_object)
remove_legend(ggplot_object)
ggplot_object |
a ggplot |
a ggplot without a legend
Removes tick marks from all axes
remove_ticks(axis = "both")
remove_ticks(axis = "both")
axis |
Axis to drop. "x", "y", or "both" |
This function can only handle up to 8 categories/colors.
scale_color_discrete(...)
scale_color_discrete(...)
... |
other arguments passed to |
If you need more than 8 colors for exploratory purposes, use ggplot2::scale_fill_discrete().
Continuous fill scale that aligns with the Urban Institute style
scale_color_gradientn( ..., colours = c("#CFE8F3", "#A2D4EC", "#73BFE2", "#46ABDB", "#1696D2", "#12719E", "#0A4C6A", "#062635"), colors = c("#CFE8F3", "#A2D4EC", "#73BFE2", "#46ABDB", "#1696D2", "#12719E", "#0A4C6A", "#062635"), values = NULL, space = "Lab", na.value = "grey50", guide = "colourbar" )
scale_color_gradientn( ..., colours = c("#CFE8F3", "#A2D4EC", "#73BFE2", "#46ABDB", "#1696D2", "#12719E", "#0A4C6A", "#062635"), colors = c("#CFE8F3", "#A2D4EC", "#73BFE2", "#46ABDB", "#1696D2", "#12719E", "#0A4C6A", "#062635"), values = NULL, space = "Lab", na.value = "grey50", guide = "colourbar" )
... |
other arguments passed to |
colours |
vector of colours |
colors |
vector of colours |
values |
if colours should not be evenly positioned along the gradient this vector gives the position (between 0 and 1) for each colour in the colours vector. See rescale for a convience function to map an arbitrary range to between 0 and 1 |
space |
colour space in which to calculate gradient. Must be "Lab" - other values are deprecated. |
na.value |
default color for NA values |
guide |
legend representation of scale |
This function can only handle up to 8 categories/colors.
scale_color_ordinal(...)
scale_color_ordinal(...)
... |
other arguments passed to |
If you need more than 8 colors for exploratory purposes, use ggplot2::scale_color_ordinal().
This function can only handle up to 8 categories/colors.
scale_colour_discrete(...)
scale_colour_discrete(...)
... |
other arguments passed to |
If you need more than 8 colors for exploratory purposes, use ggplot2::scale_color_discrete().
Continuous fill scale that aligns with the Urban Institute style
scale_colour_gradientn( ..., colours = c("#CFE8F3", "#A2D4EC", "#73BFE2", "#46ABDB", "#1696D2", "#12719E", "#0A4C6A", "#062635"), colors = c("#CFE8F3", "#A2D4EC", "#73BFE2", "#46ABDB", "#1696D2", "#12719E", "#0A4C6A", "#062635"), values = NULL, space = "Lab", na.value = "grey50", guide = "colourbar" )
scale_colour_gradientn( ..., colours = c("#CFE8F3", "#A2D4EC", "#73BFE2", "#46ABDB", "#1696D2", "#12719E", "#0A4C6A", "#062635"), colors = c("#CFE8F3", "#A2D4EC", "#73BFE2", "#46ABDB", "#1696D2", "#12719E", "#0A4C6A", "#062635"), values = NULL, space = "Lab", na.value = "grey50", guide = "colourbar" )
... |
other arguments passed to |
colours |
vector of colours |
colors |
vector of colours |
values |
if colours should not be evenly positioned along the gradient this vector gives the position (between 0 and 1) for each colour in the colours vector. See rescale for a convience function to map an arbitrary range to between 0 and 1 |
space |
colour space in which to calculate gradient. Must be "Lab" - other values are deprecated. |
na.value |
default color for NA values |
guide |
legend representation of scale |
This function can only handle up to 8 categories/colors.
scale_colour_ordinal(...)
scale_colour_ordinal(...)
... |
other arguments passed to |
If you need more than 8 colors for exploratory purposes, use ggplot2::scale_colour_ordinal().
This function can only handle up to 8 categories/colors.
scale_fill_discrete(...)
scale_fill_discrete(...)
... |
other arguments passed to |
If you need more than 8 colors for exploratory purposes, use ggplot2::scale_fill_discrete().
Continuous fill scale that aligns with the Urban Institute style
scale_fill_gradientn( ..., colours = c("#CFE8F3", "#A2D4EC", "#73BFE2", "#46ABDB", "#1696D2", "#12719E", "#0A4C6A", "#062635"), colors = c("#CFE8F3", "#A2D4EC", "#73BFE2", "#46ABDB", "#1696D2", "#12719E", "#0A4C6A", "#062635"), values = NULL, space = "Lab", na.value = "grey50", guide = "colourbar" )
scale_fill_gradientn( ..., colours = c("#CFE8F3", "#A2D4EC", "#73BFE2", "#46ABDB", "#1696D2", "#12719E", "#0A4C6A", "#062635"), colors = c("#CFE8F3", "#A2D4EC", "#73BFE2", "#46ABDB", "#1696D2", "#12719E", "#0A4C6A", "#062635"), values = NULL, space = "Lab", na.value = "grey50", guide = "colourbar" )
... |
other arguments passed to |
colours |
vector of colours |
colors |
vector of colours |
values |
if colours should not be evenly positioned along the gradient this vector gives the position (between 0 and 1) for each colour in the colours vector. See rescale for a convience function to map an arbitrary range to between 0 and 1 |
space |
colour space in which to calculate gradient. Must be "Lab" - other values are deprecated. |
na.value |
default color for NA values |
guide |
legend representation of scale |
This function can only handle up to 8 categories/colors.
scale_fill_ordinal(...)
scale_fill_ordinal(...)
... |
other arguments passed to |
If you need more than 8 colors for exploratory purposes, use ggplot2::scale_fill_ordinal().
Adds vertical grid lines to plots for scatter plots. This is useful for scatter plots because urbnthemes only supplies horizontal grid lines.
scatter_grid()
scatter_grid()
set_urbn_defaults
provides a ggplot2 theme formatted according to the
Urban Institute style guide, with sensible defaults.
set_urbn_defaults( style = "print", base_size = 8.5, base_family = "Lato", base_line_size = 0.5, base_rect_size = 0.5, scale = "continuous" )
set_urbn_defaults( style = "print", base_size = 8.5, base_family = "Lato", base_line_size = 0.5, base_rect_size = 0.5, scale = "continuous" )
style |
The default theme style for the R session. "print" or "map". |
base_size |
The base font size for the theme. All fonts are relative to this value. |
base_family |
The base font family for the theme. |
base_line_size |
The base line size for the theme. All line sizes are relative to this value. |
base_rect_size |
The base rect size for the theme. All rect sizes are relative to this value. |
scale |
For |
theme_urban
provides a ggplot2 theme formatted according to the
Urban Institute style guide for maps, with sensible defaults.
theme_urbn_map( scale = "continuous", base_size = 8.5, base_family = "Lato", base_line_size = 0.5, base_rect_size = 0.5 )
theme_urbn_map( scale = "continuous", base_size = 8.5, base_family = "Lato", base_line_size = 0.5, base_rect_size = 0.5 )
scale |
"continuous" creates a vertical legend to the right of the map. "discrete" creates a horizontal legend above the map. |
base_family , base_size
|
base font family and size |
base_line_size , base_rect_size
|
base line and rectangle sizes |
theme_urban
provides a ggplot2 theme formatted according to the
Urban Institute style guide for web, with sensible defaults.
theme_urbn_print( base_size = 8.5, base_family = "Lato", base_line_size = 0.5, base_rect_size = 0.5 )
theme_urbn_print( base_size = 8.5, base_family = "Lato", base_line_size = 0.5, base_rect_size = 0.5 )
base_family , base_size
|
base font family and size |
base_line_size , base_rect_size
|
base line and rectangle sizes |
Resets all the ggplot2 theme to its default settings
undo_urbn_defaults()
undo_urbn_defaults()
Color palettes used in the Urban Institute.
urbn_color_pal(palette = "categorical")
urbn_color_pal(palette = "categorical")
palette |
Palette name. |
Dataset used for creating geofacetted plots in the Urban Institute style.
urbn_geofacet
urbn_geofacet
Data frame with columns
Row in geofacet
Column in geofacet
State abbreviation
State name
Creates a grid object with the Urban Institute logo
urbn_logo_text()
urbn_logo_text()
Add a notes section to the bottom of a plot created with urbn_plot()
.
urbn_note(text, size = 8, width = 132, plural = FALSE)
urbn_note(text, size = 8, width = 132, plural = FALSE)
text |
character string for a note |
size |
font size for the note |
width |
a number of characters to allow before a character return |
plural |
If 'TRUE', will change "Note:" to "Notes:" |
a grob formatted for a source in a ggplot
Combine elements from urbn_title
, urbn_subtitle
,
urbn_y_title
, get_legend
, remove_legend
,
urbn_notes
, urbn_source
, and ggplot2
into
one formatted plot.
urbn_plot(..., heights = 1)
urbn_plot(..., heights = 1)
... |
urbn plot objects or grobs |
heights |
relative heights of each object in the final plot |
one plot made from many grobs
This is a function to save standardized images for Urban Institute publications. For more functionality like custom widths and heights, use ggsave() directly.
urbn_save( filename, plot = ggplot2::last_plot(), size = "medium", dpi = 300, height = NULL )
urbn_save( filename, plot = ggplot2::last_plot(), size = "medium", dpi = 300, height = NULL )
filename |
File name to create on disk. |
plot |
Plot to save, defaults to last plot displayed. |
size |
Size of plot. Must be one of "small" (3.25 x 2 inches), "medium" (6.5 x 4 inches), or "large" (9 x 6.5 inches). |
dpi |
Plot resolution. Also accepts a string input: "retina" (320), "print" (300), or "screen" (72). Applies only to raster output types. |
## Not run: library(tidyverse) library(urbnthemes) set_urbn_defaults(style = "print") cars %>% ggplot(aes(speed, dist)) + geom_point() urbn_save("test.png") ## End(Not run)
## Not run: library(tidyverse) library(urbnthemes) set_urbn_defaults(style = "print") cars %>% ggplot(aes(speed, dist)) + geom_point() urbn_save("test.png") ## End(Not run)
Add a source section to the bottom of a plot created with urbn_plot()
.
urbn_source(text, size = 8, width = 132, plural = FALSE)
urbn_source(text, size = 8, width = 132, plural = FALSE)
text |
character string for a source |
size |
font size for the source |
width |
a number of characters to allow before a character return |
plural |
If 'TRUE', will change "Source:" to "Sources:" |
a grob formatted for a source in a ggplot
Add a subtitle to a plot created with urbn_plot()
.
urbn_subtitle(string, size = 9.5)
urbn_subtitle(string, size = 9.5)
string |
character string for a subtitle |
size |
font size for the subtitle |
a grob formatted for a subtitle in a ggplot
Add a title to a plot created with urbn_plot()
.
urbn_title(string, size = 12, width = 68)
urbn_title(string, size = 12, width = 68)
string |
character string for a title |
size |
font size for the title |
width |
a number of characters to allow before a character return |
a grob formatted for a source in a ggplot
Add a horizontal y axis title to a plot created with urbn_plot()
.
urbn_y_title(string, size = 8.5)
urbn_y_title(string, size = 8.5)
string |
character string for a y-axis title |
size |
font size for the y-axis title |
a grob formatted for a y-axis title in a ggplot
view_palette
displays the colors and hexadecimal codes for palette_urbn_*
vectors.
view_palette(palette = palette_urbn_main)
view_palette(palette = palette_urbn_main)
palette |
A |
view_palette() view_palette(palette_urbn_cyan)
view_palette() view_palette(palette_urbn_cyan)