{"id":13712735,"url":"https://github.com/aljrico/harrypotter","last_synced_at":"2026-02-21T18:03:55.047Z","repository":{"id":56936486,"uuid":"140615929","full_name":"aljrico/harrypotter","owner":"aljrico","description":"🎨 Harry Potter inspired palette for R","archived":false,"fork":false,"pushed_at":"2020-03-05T19:25:18.000Z","size":87753,"stargazers_count":108,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-01-05T04:00:41.896Z","etag":null,"topics":["color-palette","harry","harry-potter","package","plot","r"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/aljrico.png","metadata":{"files":{"readme":"readme.md","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}},"created_at":"2018-07-11T18:47:03.000Z","updated_at":"2025-11-26T02:40:47.000Z","dependencies_parsed_at":"2022-08-21T06:20:38.257Z","dependency_job_id":null,"html_url":"https://github.com/aljrico/harrypotter","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/aljrico/harrypotter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aljrico%2Fharrypotter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aljrico%2Fharrypotter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aljrico%2Fharrypotter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aljrico%2Fharrypotter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aljrico","download_url":"https://codeload.github.com/aljrico/harrypotter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aljrico%2Fharrypotter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29689644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T15:51:39.154Z","status":"ssl_error","status_checked_at":"2026-02-21T15:49:03.425Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-palette","harry","harry-potter","package","plot","r"],"created_at":"2024-08-02T23:01:21.979Z","updated_at":"2026-02-21T18:03:55.028Z","avatar_url":"https://github.com/aljrico.png","language":"HTML","funding_links":[],"categories":["Themes and aesthetics","ggplot"],"sub_categories":["Palettes 🎨"],"readme":"\n# harrypotter \u003cimg src=\"man/figures/logo.png\" align=\"right\" width=\"120\" /\u003e\n\n\n[![cran version](http://www.r-pkg.org/badges/version/harrypotter)](https://cran.r-project.org/package=harrypotter)\n[![rstudio mirror per-month downloads](http://cranlogs.r-pkg.org/badges/harrypotter)](https://github.com/metacran/cranlogs.app)\n[![rstudio mirror total downloads](http://cranlogs.r-pkg.org/badges/grand-total/harrypotter?color=yellowgreen)](https://github.com/metacran/cranlogs.app)\n\nThis package provides the first round of palettes derived from the *Harry Potter* film series.\n\nAt its first version, it simply contains the palettes of the [Hogwarts](https://en.wikipedia.org/wiki/Hogwarts) Houses. They have been chosen manually, taking into account its consistency with all the existing branding of the franchise, but its suitability for data visualisation. \n\n\u003e Most of us need to _listen_ to the music to understand how beautiful it is. But often that’s how statistics are presented: we show the notes instead of playing the music.\n\nThe colour palette should be beautiful, useful for plotting data and shoulr relate to desired style; in this case, should relate to the Harry Potter world. Some of the colours might change in future versions, in order to find this balance between suitability for plotting and relatable to the Harry Potter universe.\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/harrypotter/master/readme_raw_files/examples/scales_houses.png\" \u003e\u003c/center\u003e\n\n\n\n\nInstallation\n-------------\n\nJust copy and execute this bunch of code and you'll have the last version of the package installed:\n\n\n```r\ninstall.packages(\"harrypotter\")\n```\n\nAnd you can now use it:\n\n\n```r\nlibrary(harrypotter)\n```\n\nUsage\n-----\n\nThe default colour scale of the package is the one named **Always**. If you prefer to choose another one, you'll need to specify which house you want the palette from.\n\nYou can get started using base R plot functions, and the `hp()` function. Its first argument `n` lets you set the number of colours to be mapped. This way you can set different resolutions. Let's say that you want a palette made from the house **Gryffindor**, then just type `option = \"Gryffindor\"`. \n\n\n```r\npal \u003c- hp(n = 8, house = \"Gryffindor\")\nimage(volcano, col = pal)\n\npal \u003c- hp(n = 128, house = \"Gryffindor\")\nimage(volcano, col = pal)\n```\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/harrypotter/master/readme_raw_files/examples/gryffindor_volcano.png\" \u003e\u003c/center\u003e\n\n## ggplot2\n\nOf course, this package has specific functions to behave seamlessly with the best data visiualisation library available. \nThe package contains colour scale functions for **ggplot2** plots: `scale_colour_hp()` and `scale_fill_hp()`. \n\n\nHere is a made up example using the colours from the house of **Hufflepuff**,\n\n\n```r\nlibrary(ggplot2)\nggplot(data.frame(x = rnorm(1e4), y = rnorm(1e4)), aes(x = x, y = y)) +\n  geom_hex() + \n\tcoord_fixed() +\n  scale_fill_hp(house = \"hufflepuff\") + \n\ttheme_bw()\n```\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/blog/master/_posts/images/unnamed-chunk-6-1.png\" \u003e\u003c/center\u003e\n\n\nor more made-up heatmaps:\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/blog/master/_posts/images/unnamed-chunk-8-1.png\" \u003e\u003c/center\u003e\n\n\nUsing the same function we can also plot these cloropleth maps of U.S. unemployment:\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/blog/master/_posts/images/ggplot2-1.png\" \u003e\u003c/center\u003e\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/blog/master/_posts/images/ggplot2-2.png\" \u003e\u003c/center\u003e\n\n\n### Discrete Scales\n\nBut what if you want discrete scales? These functions also can be used for discrete scales with the argument `discrete = TRUE`. This argument, when TRUE, sets a finite number of sufficiently spaced colours within the selected palette to plot your data.\n\n\n```r\nggplot(diamonds, aes(factor(color), fill=factor(cut))) +\n\tgeom_bar(colour = \"black\") +\n\tscale_fill_hp(discrete = TRUE, option = \"ronweasley2\", name = \"Cut\") +\n\tylab(\"\") +\n\txlab(\"Colour\") +\n\tcoord_flip()\n```\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/harrypotter/master/readme_raw_files/examples/ronweasley_bar.png\" \u003e\u003c/center\u003e\n\nYou can also use discrete scales by adding `_d()` at the end of it instead, like `scale_fill_hp_d()`.\n\n\n```r\ndsamp \u003c- diamonds[sample(nrow(diamonds), 1000), ]\nggplot(dsamp, aes(carat, price)) +\n\tgeom_point(aes(colour = clarity)) +\n\tscale_colour_hp_d(option = \"LunaLovegood\", name = \"Clarity\") +\n\txlab(\"Carat\") +\n\tylab(\"Price\")\n```\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/harrypotter/master/readme_raw_files/examples/lunalovegood_scatter.png\" \u003e\u003c/center\u003e\n\n\nDon't forget to try them all.\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/harrypotter/master/readme_raw_files/examples/mischief_always_tile.png\" \u003e\u003c/center\u003e\n\n\n\n# Palettes\n\n```r\noption = \"Mischief\"\n```\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/harrypotter/master/readme_raw_files/palettes/mischief.png\" width = \"75%\"\"; height=\"75%\"\u003e\u003c/center\u003e\n\n---\n\n```r\noption = \"Always\"\n```\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/harrypotter/master/readme_raw_files/palettes/always.png\" width= \"75%\"; height = \"75%\"\u003e\u003c/center\u003e\n\n---\n\n```r\noption = \"Sprout\"\n```\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/harrypotter/master/readme_raw_files/palettes/sprout.png\" width= \"75%\"; height = \"75%\"\u003e\u003c/center\u003e\n\n---\n\n```r\noption = \"LunaLovegood\"\n```\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/harrypotter/master/readme_raw_files/palettes/luna_lovegood.png\" width= \"75%\"; height = \"75%\"\u003e\u003c/center\u003e\n\n---\n\n```r\noption = \"HermioneGranger\"\n```\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/harrypotter/master/readme_raw_files/palettes/hermione_granger.png\" width= \"75%\"; height = \"75%\"\u003e\u003c/center\u003e\n\n---\n\n```r\noption = \"HarryPotter\"\n```\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/harrypotter/master/readme_raw_files/palettes/harry_potter.png\" width= \"75%\"; height = \"75%\"\u003e\u003c/center\u003e\n\n---\n\n```r\noption = \"DracoMalfoy\"\n```\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/harrypotter/master/readme_raw_files/palettes/draco_malfoy.png\" width= \"75%\"; height = \"75%\"\u003e\u003c/center\u003e\n\n---\n\n```r\noption = \"RonWeasley\"\n```\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/harrypotter/master/readme_raw_files/palettes/ron_weasley.png\" width= \"75%\"; height = \"75%\"\u003e\u003c/center\u003e\n\n---\n\n```r\noption = \"NewtScamander\"\n```\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/harrypotter/master/readme_raw_files/palettes/newt_scamander.png\" width= \"75%\"; height = \"75%\"\u003e\u003c/center\u003e\n\n---\n\n```r\noption = \"Ravenclaw\"\n```\n\n\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/aljrico/harrypotter/master/readme_raw_files/palettes/ravenclaw.png\" width= \"75%\"; height = \"75%\"\u003e\u003c/center\u003e\n\n# Acknowledgments\n\n* Special thanks to my buddy [Alfredo](https://aldomann.com) for designing the logo.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faljrico%2Fharrypotter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faljrico%2Fharrypotter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faljrico%2Fharrypotter/lists"}