MyNixOS website logo
Description

Mexican Politics-Inspired Color Palette Generator.

A color palette generator inspired by Mexican politics, with colors ranging from red on the left to gray in the middle and green on the right. Palette options range from only a few colors to several colors, but with discrete and continuous options to offer greatest flexibility to the user. This package allows for a range of applications, from mapping brief discrete scales (e.g., four colors for Morena, PRI, and PAN) to continuous interpolated arrays including dozens of shades graded from red to green.

mexicolors: A Mexican politics-inspired color palette generator

Building 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.

Installation

Dev:

devtools::install_github("alexplatasl/mexicolors")
library(mexicolors)

Use

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.

Palettes

  1. morena: two shades of red and two shades of grey.
  2. pri: four colors including green, white, grey, and red.
  3. pan: four colors including three shades of blue and one shade of white.
  4. prd: five colors including two shades of yellow, one shade of white, and two shades of grey.
  5. cuatroT: eight colors including two shades of red, two shades of yellow, two shades of gray, and two shades of green.
  6. ine: four colors including whine, mexican pink, grey, and black.
  7. pvem: six colors including three shades of green, yellow, red, and black.
  8. mc: eight colors including four shades of orange and four shades of gray..

Displaying each palette

mexico_palette("cuatroT")

mexico_palette("ine")

mexico_palette("morena")

mexico_palette("pri")

mexico_palette("pan")

mexico_palette("prd")

mexico_palette("pvem")

mexico_palette("mc")

Interpolating between existing colors based on the palettes using the "continuous" type

mexico_palette(n = 50, name = "cuatroT", type = "continuous")

mexico_palette(n = 50, name = "ine", type = "continuous")

mexico_palette(n = 50, name = "morena", type = "continuous")

mexico_palette(n = 50, name = "pri", type = "continuous")

mexico_palette(n = 50, name = "pan", type = "continuous")

mexico_palette(n = 50, name = "prd", type = "continuous")

mexico_palette(n = 50, name = "pvem", type = "continuous")

mexico_palette(n = 50, name = "mc", type = "continuous")

Example Political Cases (Discrete and Continuous)

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()

Non-Political Cases (5 and 7 level palettes)

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()

library(tidyverse)

# 7-level (discrete) palette
ggplot(diamonds, aes(factor(color), fill = factor(color))) +
  geom_bar() + 
  scale_fill_manual(values = mexico_palette("morena", 7, "continuous")) +
  theme_bw()

How do I get 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.

Metadata

Version

0.2.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows