-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24bf8a5
commit 3d70b5d
Showing
5 changed files
with
196 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
#' Wikipedia Election Map scales for `ggplot2` | ||
#' | ||
#' @rdname scale_wiki | ||
#' | ||
#' @param ... additional arguments to `ggplot::scale_*` functions | ||
#' | ||
#' @return ggplot scale function | ||
#' | ||
#' @examples | ||
#' scale_fill_wiki_rep() | ||
#' scale_fill_wiki_rep() | ||
#' scale_fill_wiki_dem() | ||
#' scale_fill_wiki_dem() | ||
#' scale_fill_wiki_rep_pres() | ||
#' scale_fill_wiki_rep_pres() | ||
#' scale_fill_wiki_dem_pres() | ||
#' scale_fill_wiki_dem_pres() | ||
#' @concept colors | ||
#' @export | ||
scale_fill_wiki_rep <- function(...) { | ||
ggplot2::binned_scale('fill', 'wiki_rep', | ||
palette = function(x) ggredist$wiki_rep, | ||
breaks = seq(0, 1, by = 0.1), | ||
limits = c(.1, .9), | ||
oob = scales::squish, | ||
guide = 'colourbar', | ||
... | ||
) | ||
} | ||
|
||
#' @rdname scale_wiki | ||
#' | ||
#' @concept colors | ||
#' @export | ||
scale_color_wiki_rep <- function(...) { | ||
ggplot2::binned_scale('color', 'wiki_rep', | ||
palette = function(x) ggredist$wiki_rep, | ||
breaks = seq(0, 1, by = 0.1), | ||
limits = c(.1, .9), | ||
oob = scales::squish, | ||
guide = 'colourbar', | ||
... | ||
) | ||
} | ||
|
||
#' @rdname scale_wiki | ||
#' | ||
#' @concept colors | ||
#' @export | ||
scale_fill_wiki_dem <- function(...) { | ||
ggplot2::binned_scale('fill', 'wiki_dem', | ||
palette = function(x) ggredist$wiki_dem, | ||
breaks = seq(0, 1, by = 0.1), | ||
limits = c(.1, .9), | ||
oob = scales::squish, | ||
guide = 'colourbar', | ||
... | ||
) | ||
} | ||
|
||
#' @rdname scale_wiki | ||
#' | ||
#' @concept colors | ||
#' @export | ||
scale_color_wiki_dem <- function(...) { | ||
ggplot2::binned_scale('color', 'wiki_dem', | ||
palette = function(x) ggredist$wiki_dem, | ||
breaks = seq(0, 1, by = 0.1), | ||
limits = c(.1, .9), | ||
oob = scales::squish, | ||
guide = 'colourbar', | ||
... | ||
) | ||
} | ||
|
||
#' @rdname scale_wiki | ||
#' | ||
#' @concept colors | ||
#' @export | ||
scale_fill_wiki_rep_pres <- function(...) { | ||
ggplot2::binned_scale('fill', 'wiki_rep_pres', | ||
palette = function(x) ggredist$wiki_rep_pres, | ||
breaks = c(0, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1), | ||
limits = c(.2, .9), | ||
oob = scales::squish, | ||
guide = 'colourbar', | ||
... | ||
) | ||
} | ||
|
||
#' @rdname scale_wiki | ||
#' | ||
#' @concept colors | ||
#' @export | ||
scale_color_wiki_rep_pres <- function(...) { | ||
ggplot2::binned_scale('color', 'wiki_rep_pres', | ||
palette = function(x) ggredist$wiki_rep_pres, | ||
breaks = c(0, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1), | ||
limits = c(.2, .9), | ||
oob = scales::squish, | ||
guide = 'colourbar', | ||
... | ||
) | ||
} | ||
|
||
#' @rdname scale_wiki | ||
#' | ||
#' @concept colors | ||
#' @export | ||
scale_fill_wiki_dem_pres <- function(...) { | ||
ggplot2::binned_scale('fill', 'wiki_dem_pres', | ||
palette = function(x) ggredist$wiki_dem_pres, | ||
breaks = c(0, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1), | ||
limits = c(.2, .9), | ||
oob = scales::squish, | ||
guide = 'colourbar', | ||
... | ||
) | ||
} | ||
|
||
#' @rdname scale_wiki | ||
#' | ||
#' @concept colors | ||
#' @export | ||
scale_color_wiki_dem_pres <- function(...) { | ||
ggplot2::binned_scale('color', 'wiki_dem_pres', | ||
palette = function(x) ggredist$wiki_dem_pres, | ||
breaks = c(0, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1), | ||
limits = c(.2, .9), | ||
oob = scales::squish, | ||
guide = 'colourbar', | ||
... | ||
) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.