{"id":22298195,"url":"https://github.com/ibarraespinosa/cptcity","last_synced_at":"2025-07-29T01:33:26.743Z","repository":{"id":44651621,"uuid":"120517547","full_name":"ibarraespinosa/cptcity","owner":"ibarraespinosa","description":"7140 colour palletes in an R package to play!","archived":false,"fork":false,"pushed_at":"2024-11-19T19:04:21.000Z","size":9695,"stargazers_count":18,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-02T11:45:07.648Z","etag":null,"topics":["color","colors","colour","colour-palette","colours","cpt-city","cptcity","gradient","r"],"latest_commit_sha":null,"homepage":"https://ibarraespinosa.github.io/cptcity/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ibarraespinosa.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-02-06T20:11:49.000Z","updated_at":"2024-10-20T23:20:37.000Z","dependencies_parsed_at":"2022-09-10T21:31:02.945Z","dependency_job_id":"a2ed79d6-82af-4912-9f5f-52fccee462d2","html_url":"https://github.com/ibarraespinosa/cptcity","commit_stats":{"total_commits":57,"total_committers":8,"mean_commits":7.125,"dds":0.3157894736842105,"last_synced_commit":"2bd776edf03f024f53872d60a8af4af2c2406b2b"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibarraespinosa%2Fcptcity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibarraespinosa%2Fcptcity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibarraespinosa%2Fcptcity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibarraespinosa%2Fcptcity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ibarraespinosa","download_url":"https://codeload.github.com/ibarraespinosa/cptcity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227894307,"owners_count":17836378,"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":["color","colors","colour","colour-palette","colours","cpt-city","cptcity","gradient","r"],"created_at":"2024-12-03T18:00:05.306Z","updated_at":"2025-07-29T01:33:26.737Z","avatar_url":"https://github.com/ibarraespinosa.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\ntitle: \"cptcity package\"\nauthor: \"Sergio Ibarra-Espinosa\"\ndate: \"`r Sys.Date()`\"\noutput: github_document\nalways_allow_html: true\n---\n\n![](https://i.imgur.com/4v9WMQv.gif)\n\n[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/ibarraespinosa/cptcity?branch=master\u0026svg=true)](https://ci.apalettepveyor.com/project/ibarraespinosa/cptcity)\n[![DOI](https://zenodo.org/badge/120517547.svg)](https://zenodo.org/badge/latestdoi/120517547)\n[![Coverage status](https://codecov.io/gh/ibarraespinosa/cptcity/branch/master/graph/badge.svg)](https://codecov.io/github/ibarraespinosa/cptcity?branch=master)\n[![](http://cranlogs.r-pkg.org/badges/cptcity)](http://cran.rstudio.com/web/packages/cptcity/index.html)\n[![Rdoc](http://www.rdocumentation.org/badges/version/cptcity)](http://www.rdocumentation.org/packages/cptcity)\n[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/cptcity)](http://cran.r-project.org/web/packages/cptcity) \n[![CRAN Downloads](http://cranlogs.r-pkg.org/badges/grand-total/cptcity?color=orange)](http://cran.r-project.org/package=cptcity)\n\n## A package to return colour gradients from CPTCITY\n\nColour palettes comes from http://soliton.vm.bytemark.co.uk/pub/cpt-city/index.html\n\nCurrently there are 7140 colour gradients. To se the names type `cpt_names`.\n\nThere are three functions:\n\n1) `find_cpt`: To search the name of the colour gradient.\n\nExample:\n\n```{r}\nlibrary(cptcity)\nfind_cpt(\"radar\")\n\n```\n\n\n2) `show_cpt`: Visually selectyour palette\n\n\n```{r}\npals \u003c- find_cpt(\"radar\")\nshow_cpt(pals)\n```\n\n\n\n3) `cpt`: To return the colour gradient.\n\n```{r}\ncptcity::cpt(pal = \"ncl_radar_1\", n = 100)\n\n```\n\n\n4) `lucky`: To choose a random colour gradient\n```{r}\ncptcity::lucky(n = 100)\n\n```\n\n\n## Install and use it!\n\n```{r eval = T}\n# install.packages(\"cptcity\") 1.0.6\n# remotes::install_github(\"ibarraespinosa/cptcity\") \npackageVersion(\"cptcity\")\nlibrary(cptcity)\nimage(matrix(1:100), col = cpt(pal = \"mpl_inferno\"))\n```\n\n## ggplot2\n\nAnd you can use it ggplot2\n```{r}\nlibrary(cptcity)\nlibrary(ggplot2)\nggplot(faithfuld, aes(waiting, eruptions)) +\n  geom_raster(aes(fill = density))\n```\n\n\n```{r}\nggplot(faithfuld, aes(waiting, eruptions)) +\n  geom_raster(aes(fill = density)) +\n  scale_fill_gradientn(colours = cpt())\n\n```\n\n## raster\n\n```{r}\nlibrary(cptcity)\nlibrary(raster)\nf \u003c- system.file(\"external/test.grd\", package=\"raster\")\nr \u003c- raster(f)\nspplot(r, scales = list(draw = T))\n```\n\n\n```{r}\nspplot(r, scales = list(draw = T),\n       col.regions = rev(cpt(n = 100, pal = \"colo_Skyblue2u_Gentle_Waves\")))\n```\n\n\n## sf\n```{r}\nlibrary(cptcity)\nlibrary(sf)\nnc = st_read(system.file(\"shape/nc.shp\", package=\"sf\"))\nplot(nc[\"AREA\"], pal = cpt(colorRampPalette = T))\n```\n\n\n## mapview\n\n\n```{r, eval = F}\nlibrary(cptcity)\nlibrary(mapview)\nlibrary(sf)\nnc = st_read(system.file(\"shape/nc.shp\", package=\"sf\"))\nmapview(nc, zcol = \"AREA\", col.regions = cpt(colorRampPalette = T), legend = T)\n```\n![](https://camo.githubusercontent.com/a56248d08ddf653a62ee23ea8855cc24e77a2c69/68747470733a2f2f692e696d6775722e636f6d2f78664f6265626e2e706e67)\n\n\n## stars\n\n\n```{r}\nlibrary(cptcity)\nlibrary(stars)\ntif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\")\n(x1 = read_stars(tif))\nbr \u003c- classInt::classIntervals(var = x1$L7_ETMs.tif, \n                               n = 100, \n                               style = \"sd\")\nplot(x1,\n     axes = TRUE,\n     lty = 0,\n     col = cptcity::cpt(rev = TRUE, \n                        pal = 819,\n                        n = length(br$brks) - 1),\n     key.pos = 2,\n     breaks = br$brks\n     )\n\n```\n\n\n## terra\n\n\n```{r}\nlibrary(cptcity)\nlibrary(terra)\nf \u003c- system.file(\"ex/elev.tif\", package=\"terra\")\nr \u003c- rast(f)\nimage(r, col = cptcity::lucky())\n# Colour gradient: dca_alarm.p4.0.1, number: 1115 \n```\n\n\n# **I included a random colour gradient function!**\n\n```r\n# install.packages(\"cptcity\")\n# devtools::install_github(\"ibarraespinosa/cptcity\")\nlibrary(cptcity)\nimage(matrix(1:100), col = lucky())\n```\n\n## COPYING\n\nEach palette has a COPYING.XML files available at ins/extdata. To see each file do:\n\n```r\nlibrary(cptcity)\nfiles \u003c- list.files(system.file(\"extdata\",\n                                package = \"cptcity\"),\n                    pattern = \".xml\",\n                    recursive = T,\n                    full.names = T)\n# For instance, the COPYING files of \"arendal\" is\nfiles[1]\n# and the file\nreadLines(files[1])\n1] \"/usr/local/lib/R/site-library/cptcity/extdata/arendal/COPYING.xml\"\n [1] \"\u003c?xml version=\\\"1.0\\\"?\u003e\"                                                                        \n [2] \"\u003ccopying\u003e\"                                                                                      \n [3] \"  \u003cauthors\u003e\"                                                                                    \n [4] \"    \u003cauthor href=\\\"http://www.grida.no/graphicslib/\\\"\u003e\"                                         \n [5] \"      \u003cname\u003eGRID-Arendal\u003c/name\u003e\"                                                                \n [6] \"    \u003c/author\u003e\"                                                                                  \n [7] \"  \u003c/authors\u003e\"                                                                                   \n [8] \"  \u003clicense\u003e\"                                                                                    \n [9] \"    \u003cinformal\u003e\"                                                                                 \n[10] \"      Attribution and linkback requested.\"                                                      \n[11] \"    \u003c/informal\u003e\"                                                                                \n[12] \"    \u003cyear\u003e2014\u003c/year\u003e\"                                                                          \n[13] \"    \u003ctext\u003e\"                                                                                     \n[14] \"      Using this graphic and referring to it is encouraged, \"                                   \n[15] \"      and please use it in presentations, web pages, newspapers, \"                              \n[16] \"      blogs and reports.\"                                                                       \n[17] \"\"                                                                                               \n[18] \"      For any form of publication, please include the link to \"                                 \n[19] \"      this page and give the cartographer/designer credit.\"                                     \n[20] \"    \u003c/text\u003e\"                                                                                    \n[21] \"  \u003c/license\u003e\"                                                                                   \n[22] \"  \u003csrc\u003e\"                                                                                        \n[23] \"    \u003cformat\u003ePNG images\u003c/format\u003e\"                                                                \n[24] \"    \u003clink href=\\\"http://www.grida.no/graphicslib/detail/mean-surface-temperature_c7e4\\\"\"        \n[25] \"\\t  \u003eTemperature\u003c/link\u003e\"                                                                        \n[26] \"    \u003clink href=\\\"http://www.grida.no/graphicslib/detail/arctic-topography-and-bathymetry_5645\\\"\"\n[27] \"\\t  \u003eArctic bathymetry\u003c/link\u003e\"                                                                  \n[28] \"    \u003clink href=\\\"http://www.grida.no/graphicslib/detail/map-of-zimbabwe_36a5\\\"\"                 \n[29] \"\\t  \u003eZambezi\u003c/link\u003e\"                                                                            \n[30] \"  \u003c/src\u003e\"                                                                                       \n[31] \"  \u003cdistribute\u003e\"                                                                                 \n[32] \"    \u003cqgis distribute=\\\"yes\\\" license=\\\"other\\\"/\u003e\"                                               \n[33] \"  \u003c/distribute\u003e\"                                                                                \n[34] \"\u003c/copying\u003e\"  \n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibarraespinosa%2Fcptcity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fibarraespinosa%2Fcptcity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibarraespinosa%2Fcptcity/lists"}