{"id":13712786,"url":"https://paezha.github.io/MexBrewer/","last_synced_at":"2025-05-06T22:31:32.916Z","repository":{"id":65343781,"uuid":"442955741","full_name":"paezha/MexBrewer","owner":"paezha","description":"Color Palettes Inspired by Works Mexican Muralists","archived":false,"fork":false,"pushed_at":"2023-02-24T13:35:03.000Z","size":14599,"stargazers_count":25,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T21:35:20.311Z","etag":null,"topics":["colors","dataviz","mexico","rstats","rstats-package","rtistry"],"latest_commit_sha":null,"homepage":"https://paezha.github.io/MexBrewer/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paezha.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-12-30T03:30:11.000Z","updated_at":"2025-03-31T14:57:36.000Z","dependencies_parsed_at":"2024-01-07T01:43:29.040Z","dependency_job_id":"0bdb882b-0cbf-4c11-ba31-7bd15e8e5410","html_url":"https://github.com/paezha/MexBrewer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paezha%2FMexBrewer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paezha%2FMexBrewer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paezha%2FMexBrewer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paezha%2FMexBrewer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paezha","download_url":"https://codeload.github.com/paezha/MexBrewer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252779087,"owners_count":21802880,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["colors","dataviz","mexico","rstats","rstats-package","rtistry"],"created_at":"2024-08-02T23:01:22.682Z","updated_at":"2025-05-06T22:31:29.068Z","avatar_url":"https://github.com/paezha.png","language":"R","funding_links":[],"categories":["Themes and aesthetics"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# MexBrewer [\u003cimg src=\"man/figures/MexBrewer.png\" align=\"right\" width=300 /\u003e](https://paezha.github.io/MexBrewer/)\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/MexBrewer)](https://CRAN.R-project.org/package=MexBrewer)\n\n[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-green.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)\n\n[![GitHub Stars](https://img.shields.io/github/stars/paezha/MexBrewer?style=social)](https://github.com/paezha/MexBrewer/stargazers)\n\n![GitHub search hit counter: R](https://img.shields.io/github/search/paezha/MexBrewer/R)  \n![GitHub search hit counter: dataviz](https://img.shields.io/github/search/paezha/MexBrewer/dataviz)\n![GitHub search hit counter: colors](https://img.shields.io/github/search/paezha/MexBrewer/colors)\n![GitHub search hit counter: rtistry](https://img.shields.io/github/search/paezha/MexBrewer/rtistry)\n\n![GitHub issues](https://img.shields.io/github/issues/paezha/MexBrewer)\n![GitHub release](https://img.shields.io/github/release-date/paezha/MexBrewer)\n![GitHub commit activity](https://img.shields.io/github/commit-activity/y/paezha/MexBrewer)\n![GitHub last commit](https://img.shields.io/github/last-commit/paezha/MexBrewer)\n[![](https://cranlogs.r-pkg.org/badges/mexbrewer)](https://cran.r-project.org/package=mexbrewer)\n\u003c!-- badges: end --\u003e\n\nMexBrewer is a package with color palettes inspired by the works of\nMexican painters and muralists. This package was motivated and draws heavily from the code of [Blake R. Mills](https://github.com/BlakeRMills/)'s\n[{MetBrewer}](https://github.com/BlakeRMills/MetBrewer), the package with color\npalettes form the Metropolitan Museum of Art of New York. The structure of the package and coding, like {MetBrewer}, are based on [{PNWColors}](https://github.com/jakelawlor/PNWColors) and [{wesanderson}](https://github.com/karthik/wesanderson).\n\n## Installation\n\nThe package is available from CRAN:\n```r\ninstall.packages(\"MexBrewer\")\n```\n\nThe development version of the package can be installed like so:\n``` r\nif (!require(\"remotes\")) install.packages(\"remotes\")\nremotes::install_github(\"paezha/MexBrewer\") \n```\n\n## Artists\n\n### Electa Arenal\n\n#### Revolución\n\nThis palette is called `Revolucion`.\n\n```{r revolucion, echo=FALSE, out.width=\"400px\", fig.cap=\"Revolucion\"}\nknitr::include_graphics(\"man/figures/electa_arenal_revolucion.jpg\")\n```\n\n```{r revolucion-palette, echo=FALSE, out.width=\"185px\", fig.cap=\"Revolucion\"}\nknitr::include_graphics(\"man/figures/revolucion.png\")\n```\n\n***\n\n### Olga Costa\n\n#### Naturaleza\n\nThis palette is called `Naturaleza`.\n\n```{r naturaleza, echo=FALSE, out.width=\"400px\", fig.cap=\"Naturaleza\"}\nknitr::include_graphics(\"man/figures/olga_costa_naturaleza.jpg\")\n```\n\n```{r naturaleza-palette, echo=FALSE, out.width=\"185px\", fig.cap=\"Naturaleza\"}\nknitr::include_graphics(\"man/figures/naturaleza.png\")\n```\n\n#### Ofrenda\n\nThis palette is called `Ofrenda`.\n\n```{r ofrenda, echo=FALSE, out.width=\"400px\", fig.cap=\"Ofrenda\"}\nknitr::include_graphics(\"man/figures/olga_costa_ofrenda.jpg\")\n```\n\n```{r ofrenda-palette, echo=FALSE, out.width=\"185px\", fig.cap=\"Ofrenda\"}\nknitr::include_graphics(\"man/figures/ofrenda.png\")\n```\n\n#### Vendedora\n\nThis palette is called `Vendedora`.\n\n```{r vendedora, echo=FALSE, out.width=\"400px\", fig.cap=\"Vendedora\"}\nknitr::include_graphics(\"man/figures/olga_costa_vendedora.jpg\")\n```\n\n```{r vendedora-palette, echo=FALSE, out.width=\"185px\", fig.cap=\"Vendedora\"}\nknitr::include_graphics(\"man/figures/vendedora.png\")\n```\n\n***\n\n### María Izquierdo\n\n#### Alacena\n\nThis palette is called `Alacena`.\n\n```{r alacena, echo=FALSE, out.width=\"400px\", fig.cap=\"Alacena\"}\nknitr::include_graphics(\"man/figures/maria_izquierdo_alacena.jpg\")\n```\n\n```{r alacena-palette, echo=FALSE, out.width=\"185px\", fig.cap=\"Alacena\"}\nknitr::include_graphics(\"man/figures/alacena.png\")\n```\n\n#### La Tierra\n\nThis palette is called `Tierra`.\n\n```{r tierra, echo=FALSE, out.width=\"400px\", fig.cap=\"Tierra\"}\nknitr::include_graphics(\"man/figures/maria_izquierdo_tierra.jpg\")\n```\n\n```{r tierra-palette, echo=FALSE, out.width=\"185px\", fig.cap=\"Tierra\"}\nknitr::include_graphics(\"man/figures/tierra.png\")\n```\n\n***\n\n### Frida Khalo\n\n#### La Casa Azul\n\nThese palettes are called `Casita1`, `Casita2`, and `Casita3`. They are inspired by the colors of [Frida's home](https://www.museofridakahlo.org.mx/museo/) in Coyoacán, Mexico City.\n\n```{r casa-azul-1, echo=FALSE, out.width=\"400px\", fig.cap=\"Casa Azul\"}\nknitr::include_graphics(\"man/figures/casa-azul-1.jpg\")\n```\n\n```{r casa-azul-2, echo=FALSE, out.width=\"400px\", fig.cap=\"Casa Azul\"}\nknitr::include_graphics(\"man/figures/casa-azul-2.jpg\")\n```\n\n```{r casa-azul-3, echo=FALSE, out.width=\"400px\", fig.cap=\"Casa Azul\"}\nknitr::include_graphics(\"man/figures/casa-azul-3.jpg\")\n```\n\n```{r casa-azul-4, echo=FALSE, out.width=\"400px\", fig.cap=\"Casa Azul\"}\nknitr::include_graphics(\"man/figures/casa-azul-4.jpg\")\n```\n\n```{r casa-azul-5, echo=FALSE, out.width=\"400px\", fig.cap=\"Casa Azul\"}\nknitr::include_graphics(\"man/figures/casa-azul-5.jpg\")\n```\n\n```{r casa-azul-6, echo=FALSE, out.width=\"400px\", fig.cap=\"Casa Azul\"}\nknitr::include_graphics(\"man/figures/casa-azul-6.jpg\")\n```\n\n```{r casita-1-palette, echo=FALSE, out.width=\"185px\", fig.cap=\"Casita1\"}\nknitr::include_graphics(\"man/figures/casita-1.png\")\n```\n\n```{r casita-2-palette, echo=FALSE, out.width=\"185px\", fig.cap=\"Casita2\"}\nknitr::include_graphics(\"man/figures/casita-2.png\")\n```\n\n```{r casita-3-palette, echo=FALSE, out.width=\"185px\", fig.cap=\"Casita3\"}\nknitr::include_graphics(\"man/figures/casita-3.png\")\n```\n\n***\n\n### Rina Lazo\n\n#### Venerable Abuelo Maiz\n\nThis palette is called `Maiz`.\n\n```{r maiz, echo=FALSE, out.width=\"400px\", fig.cap=\"Maiz\"}\nknitr::include_graphics(\"man/figures/rina_lazo_maiz.jpg\")\n```\n\n```{r maiz-palette, echo=FALSE, out.width=\"185px\", fig.cap=\"Maiz\"}\nknitr::include_graphics(\"man/figures/maiz.png\")\n```\n\n***\n\n### Fanny Rabel\n\n#### La Ronda del Tiempo\n\nThis palette is called `Ronda`.\n\n```{r ronda, echo=FALSE, out.width=\"400px\", fig.cap=\"Ronda\"}\nknitr::include_graphics(\"man/figures/fanny_rabel_ronda.jpg\")\n```\n\n```{r ronda-palette, echo=FALSE, out.width=\"185px\", fig.cap=\"Ronda\"}\nknitr::include_graphics(\"man/figures/ronda.png\")\n```\n\n***\n\n### Aurora Reyes\n\n#### El atentado a las maestras rurales\n\nThis palette is called `Atentado`.\n\n```{r echo=FALSE, out.width=\"400px\", fig.cap=\"Aurora, Concha, y Frida\"}\nknitr::include_graphics(\"man/figures/aurora_reyes_atentado.jpeg\")\n```\n\n```{r echo=FALSE, out.width=\"185px\", fig.cap=\"Aurora\"}\nknitr::include_graphics(\"man/figures/atentado.png\")\n```\n\n#### Aurora, Concha, y Frida\n\nThis work of Aurora Rivera inspired three palettes, called `Aurora`, `Concha`, and `Frida`.\n\n```{r auroa-concha-frida, echo=FALSE, out.width=\"400px\", fig.cap=\"Aurora, Concha, y Frida\"}\nknitr::include_graphics(\"man/figures/aurora_concha_frida.jpg\")\n```\n\n```{r aurora-palette, echo=FALSE, out.width=\"185px\", fig.cap=\"Aurora\"}\nknitr::include_graphics(\"man/figures/aurora.png\")\n```\n\n```{r concha-palette, echo=FALSE, out.width=\"185px\", fig.cap=\"Concha\"}\nknitr::include_graphics(\"man/figures/concha.png\")\n```\n\n```{r frida-palette, echo=FALSE, out.width=\"185px\", fig.cap=\"Frida\"}\nknitr::include_graphics(\"man/figures/frida.png\")\n```\n***\n\n### Remedios Varo\n\n#### La Huida\n\nThis palette is called `Huida`.\n\n```{r echo=FALSE, out.width=\"400px\", fig.cap=\"La Huida\"}\nknitr::include_graphics(\"man/figures/remedios_varo_huida.jpg\")\n```\n\n```{r echo=FALSE, out.width=\"185px\", fig.cap=\"Huida\"}\nknitr::include_graphics(\"man/figures/huida.png\")\n```\n\n#### Taurus\n\nThis work of Remedios Varo inspired two palettes, called `Taurus1` and `Taurus2`.\n\n```{r Taurus, echo=FALSE, out.width=\"400px\", fig.cap=\"Taurus\"}\nknitr::include_graphics(\"man/figures/remedios_varo_taurus.jpg\")\n```\n\n```{r taurus1-palette, echo=FALSE, out.width=\"185px\", fig.cap=\"Taurus1\"}\nknitr::include_graphics(\"man/figures/taurus1.png\")\n```\n\n```{r taurus2-palette, echo=FALSE, out.width=\"185px\", fig.cap=\"Taurus2\"}\nknitr::include_graphics(\"man/figures/taurus2.png\")\n```\n\n***\n\n## Examples \n\n```{r load-packges, message=FALSE, warning=FALSE}\nlibrary(aRtsy) # Koen Derks' package for generative art \nlibrary(flametree) # Danielle Navarro's package for generative art\nlibrary(MexBrewer)\nlibrary(sf)\nlibrary(tidyverse)\n```\n\nInvoke data sets used in the examples:\n```{r load-data}\ndata(\"mx_estados\") # Simple features object with the boundaries of states in Mexico\ndata(\"df_mxstate_2020\") # Data from {mxmaps }with population statistics at the state level\n```\n\nJoin population statistics to state boundaries:\n```{r prepare-data}\nmx_estados \u003c- mx_estados |\u003e\n  left_join(df_mxstate_2020 |\u003e\n              #Percentage of population that speak an indigenous language\n              mutate(pct_ind_lang = indigenous_language/pop * 100) |\u003e \n              dplyr::transmute(pop2020 = pop,\n                               am2020 = afromexican,\n                               state_name, \n                               pct_ind_lang),\n            by = c(\"nombre\" = \"state_name\"))\n```\n\nDistribution of population by geographic region in Mexico:\n```{r population-distribution}\nggplot(data = mx_estados,\n       aes(x = region, y = pop2020, fill = region)) +\n  geom_boxplot() +\n  scale_fill_manual(values = mex.brewer(\"Concha\", n = 5)) +\n  theme_minimal()\n```\n\nPercentage of population who speak an indigenous language in 2020 by state:\n```{r indigenous-languages}\nggplot() +\n  geom_sf(data = mx_estados,\n          aes(fill = pct_ind_lang),\n          color = \"white\",\n          size = 0.08) +\n  scale_fill_gradientn(colors = mex.brewer(\"Tierra\")) +\n  theme_minimal()\n```\n\n# Some Rtistry\n\n### Danielle Navarro's [{flametree}](https://github.com/djnavarro/flametree)\n\nThe following three images were created using the {flametree} package.\n\n```{r flametree-1, cache=TRUE}\n# pick some colours\nshades \u003c- MexBrewer::mex.brewer(\"Vendedora\") |\u003e\n  as.vector()\n\n# data structure defining the trees\ndat \u003c- flametree_grow(seed = 3563,\n                      time = 11, \n                      trees = 10)\n\n# draw the plot\ndat |\u003e \n  flametree_plot(\n    background = shades[1],\n    palette = shades[2:length(shades)], \n    style = \"nativeflora\"\n  )\n```\n\n```{r flametree-2, cache=TRUE}\n# pick some colours\nshades \u003c- MexBrewer::mex.brewer(\"Concha\") |\u003e\n  as.vector()\n\n# data structure defining the trees\ndat \u003c- flametree_grow(seed = 3536,\n                      time = 8, \n                      trees = 6)\n\n# draw the plot\ndat |\u003e \n  flametree_plot(\n    background = shades[1],\n    palette = rev(shades[2:length(shades)]), \n    style = \"wisp\"\n  )\n```\n\n```{r flametree-3, cache=TRUE}\n# pick some colours\nshades \u003c- MexBrewer::mex.brewer(\"Maiz\") |\u003e\n  as.vector()\n\n# data structure defining the trees\ndat \u003c- flametree_grow(seed = 3653,\n                      time = 8, \n                      trees = 6)\n\n# draw the plot\ndat |\u003e \n  flametree_plot(\n    background = shades[1],\n    palette = shades[2:length(shades)], \n    style = \"minimal\"\n  )\n```\n\n### Koen Derks's [aRtsy](https://github.com/koenderks/aRtsy)\n\nThe following three images were created using the {aRtsy} package.\n\nFunctions:\n```{r aRtsy-1, cache=TRUE}\nmy_formula \u003c- list(\n  x = quote(runif(1, -1, 1) * x_i^2 - sin(y_i^2)),\n  y = quote(runif(1, -1, 1) * y_i^3 - cos(x_i^2))\n)\n\ncanvas_function(colors = mex.brewer(\"Atentado\"), \n                polar = FALSE,\n                by = 0.005,\n                formula = my_formula)\n```\n\nMosaic:\n```{r aRtsy-2, cache=TRUE}\ncanvas_squares(colors = mex.brewer(\"Alacena\"), \n               cuts = 20,\n               ratio = 1.5,\n               resolution = 200,\n               noise = TRUE)\n```\n\nMandelbrot's set:\n```{r aRtsy-3, cache=TRUE}\ncanvas_mandelbrot(colors = mex.brewer(\"Naturaleza\"), \n                  zoom = 8,\n                  iterations = 200,\n                  resolution = 500)\n```\n\n### Meghan S. Harris's [waves](https://thetidytrekker.com/rtistry.html)\n\nThese plots are adaptations of Meghan Harris's artsy waves. Create data frames with wave functions:\n```{r}\n##Set up the \"range\" on the x axis for horizontal waves=====\nwave_theta \u003c- seq(from = -pi,\n                  to = -0, \n                  by = 0.01) \n\n# Create waves using functions\nwave_1 \u003c- data.frame(x = wave_theta) |\u003e \n  mutate(y = (sin(x) * cos(2 * wave_theta) + exp(x * 2)))\n\nwave_2 \u003c- data.frame(x = wave_theta) |\u003e\n  mutate(y = (0.5 * sin(x) * cos(2.0 * wave_theta) + exp(x)) - 0.5)\n```\n\n\u003c!--\n\n```{r}\nggplot() +\n  geom_ribbon(data = wave_1,\n              aes(x, min = y - 0.025, \n                  ymax = y + 0.025),\n              color = \"black\",\n              fill = \"orange\") +\n  geom_ribbon(data = wave_2,\n              aes(x, min = y - 0.025, \n                  ymax = y + 0.025),\n              color = \"black\",\n              fill = \"blue\")\n```\n\n--\u003e\n\nDefine a function to convert a single wave into a set of `n` waves. The function takes a data frame with a wave function and returns a data frame with `n` waves:\n```{r}\n# Creating a function for iterations====\n\nwave_maker \u003c- function(wave_df, n, shift){\n  \n  #Create an empty list to store our multiple dataframes(waves)#\n  wave_list\u003c- list()\n  \n  #Create a for loop to iteratively make \"n\" waves shifted a distance `shift` from each other #\n  for(i in seq_along(1:n)){\n    \n    wave_list[[i]] \u003c- wave_df |\u003e\n      mutate(y = y - (shift * i),\n             group = i)  \n  }\n  \n  #return the completed data frame to the environment#\n  return(bind_rows(wave_list))\n}\n```\n\nCreate layered waves using the data frames with the wave functions above:\n```{r}\nwave_layers \u003c- rbind(wave_1 |\u003e\n                       wave_maker(n = 5, \n                                  shift = 0.075),\n                     wave_2 |\u003e\n                       wave_maker(n = 5, \n                                  shift = 0.075) |\u003e\n                       mutate(group = group + 5)) # adjust the group counter to identify waves uniquely\n```\n\nPlot layered waves using cartesian coordinates and palette `Ofrenda`:\n```{r}\nggplot(wave_layers) +\n  geom_rect(aes(xmin = -pi, \n                xmax = -0.0, \n                ymin = min(y) - 0.50,\n                ymax = max(y) + 0.30 ),\n            size = 2.5,\n            color = mex.brewer(\"Ofrenda\")[6],\n            fill = mex.brewer(\"Ofrenda\")[4]) +\n  geom_rect(aes(xmin = -pi, \n                xmax = -0.0, \n                ymin = min(y) - 0.50,\n                ymax = max(y) + 0.30 ),\n            size = 1,\n            color = \"black\",\n            fill = NA) +\n  geom_ribbon(aes(x, \n                  ymin = y - 0.025 * 4 * x,\n                  ymax = y + 0.015 * 10 * x, \n                  group = group, \n                  fill = group),\n              color = \"black\",\n              size = 0.5) + \n  scale_fill_gradientn(colors = mex.brewer(\"Ofrenda\"))+\n  theme_void() +\n  theme(legend.position = \"none\")\n```\n\nPlot layered waves using polar coordinates and palette `Atentado`:\n```{r}\nggplot(wave_layers) +\n  geom_rect(aes(xmin = -pi, \n                xmax = -0.0, \n                ymin = min(y) - 0.45,\n                ymax = max(y) + 0.30 ),\n            size = 2.5,\n            color = mex.brewer(\"Atentado\")[6],\n            fill = mex.brewer(\"Atentado\")[3]) +\n  geom_rect(aes(xmin = -pi, \n                xmax = -0.0, \n                ymin = min(y) - 0.45,\n                ymax = max(y) + 0.30 ),\n            size = 1,\n            color = \"black\",\n            fill = NA) +\n  geom_ribbon(aes(x, \n                  ymin = y - 0.025 * 4 * x,\n                  ymax = y + 0.015 * 10 * x, \n                  group = group, \n                  fill = group),\n              color = \"black\",\n              size = 0.5) + \n  scale_fill_gradientn(colors = mex.brewer(\"Atentado\")) +\n  coord_polar(theta = \"x\",  \n              start = 0, \n              direction = 1, \n              clip = \"on\") +\n  theme_void() +\n  theme(legend.position = \"none\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/paezha.github.io%2FMexBrewer%2F","html_url":"https://awesome.ecosyste.ms/projects/paezha.github.io%2FMexBrewer%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/paezha.github.io%2FMexBrewer%2F/lists"}