The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
mexicolors
:
A Mexican politics-inspired color palette generatorBuilding on Philip Waggoner’s approach to designing color palettes in
the amerika
package, the mexicolors
package
offers a variety of a Mexican politics-inspired color palettes for a
host of applications both in and out of politics.
Palette options range from only a few colors to several colors, but
with discrete and continuous options to offer greatest flexibility to
the user. mexicolors
allows for a range of applications,
from mapping brief discrete scales to continuous interpolated arrays
including dozens of shades graded from green to red. See below for a
list of the palettes followed by a few political and non-political
examples.
Dev:
{r } devtools::install_github("alexplatasl/mexicolors") library(mexicolors)
Users simply supply the name of the desired palette in the main
function mexico_palette()
, along with the number of colors
desired from the palette (e.g., only 4 from a 5-color palette), and
whether “continuous” or “discrete” type
mapping is
desired.
morena
: two shades of red and two shades of grey.pri
: four colors including green, white, grey, and
red.pan
: four colors including three shades of blue and one
shade of white.prd
: five colors including two shades of yellow, one
shade of white, and two shades of grey.cuatroT
: eight colors including two shades of red, two
shades of yellow, two shades of gray, and two shades of green.ine
: four colors including whine, mexican pink, grey,
and black.pvem
: six colors including three shades of green,
yellow, red, and black.mc
: eight colors including four shades of orange and
four shades of gray..{r } mexico_palette("cuatroT")
{r } mexico_palette("ine")
{r } mexico_palette("morena")
{r } mexico_palette("pri")
{r } mexico_palette("pan")
{r } mexico_palette("prd")
{r } mexico_palette("pvem")
{r } mexico_palette("mc")
type
{r } mexico_palette(n = 50, name = "cuatroT", type = "continuous")
{r } mexico_palette(n = 50, name = "ine", type = "continuous")
{r } mexico_palette(n = 50, name = "morena", type = "continuous")
{r } mexico_palette(n = 50, name = "pri", type = "continuous")
{r } mexico_palette(n = 50, name = "pan", type = "continuous")
{r } mexico_palette(n = 50, name = "prd", type = "continuous")
{r } mexico_palette(n = 50, name = "pvem", type = "continuous")
{r } mexico_palette(n = 50, name = "mc", type = "continuous")
```{r } library(tidyverse) # Continuous: “ideology” on a 100 point scale (hypothetical for demo purposes only) data1 <- data.frame(sample(1:100, 3000, replace=TRUE))
data1 <- data1 %>% rename(id = sample.1.100..3000..replace…TRUE.) %>% as.data.frame()
ggplot(data1, aes(id)) + geom_bar(fill=mexico_palette(n = 100, name = “cuatroT”, type = “continuous”)) + labs(x = “Political Ideology (Liberal - Conservative)”, y = “Count of Respondents”) + theme_bw()
![](examples/lev100.png)
### Non-Political Cases (5 and 7 level palettes)
```{r }
library(tidyverse)
# 5-level (discrete) palette
ggplot(diamonds, aes(factor(cut), fill = factor(cut))) +
geom_bar() +
scale_fill_manual(values = mexico_palette("cuatroT", 5, "discrete")) +
theme_bw()
```{r } library(tidyverse)
ggplot(diamonds, aes(factor(color), fill = factor(color))) + geom_bar() + scale_fill_manual(values = mexico_palette(“morena”, 7, “continuous”)) + theme_bw() ```
mexicolors
?mexicolors
is stored and developed at this GitHub
repository, https://github.com/alexplatasl/mexicolors/, along with
an issue
tracker for reporting bugs as well as suggesting package extensions
and/or enhancements. In the spirit of open science, any level of
interaction with the package is allowed.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.