{"id":13445135,"url":"https://github.com/hrbrmstr/hrbrthemes","last_synced_at":"2025-05-14T14:07:08.166Z","repository":{"id":40636964,"uuid":"81667483","full_name":"hrbrmstr/hrbrthemes","owner":"hrbrmstr","description":":lock_with_ink_pen: Opinionated, typographic-centric ggplot2 themes and theme components","archived":false,"fork":false,"pushed_at":"2025-04-30T11:49:56.000Z","size":18982,"stargazers_count":1274,"open_issues_count":32,"forks_count":95,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-04-30T13:02:30.775Z","etag":null,"topics":["data-visualization","datavisualization","ggplot-extension","ggplot2","ggplot2-scales","ggplot2-themes","r","rstats","visualization"],"latest_commit_sha":null,"homepage":"","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/hrbrmstr.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":".github/FUNDING.yml","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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"hrbrmstr"}},"created_at":"2017-02-11T17:03:01.000Z","updated_at":"2025-04-30T11:49:59.000Z","dependencies_parsed_at":"2024-05-02T08:56:58.291Z","dependency_job_id":"70e673d6-f1d1-4a99-bf90-10f7d000867f","html_url":"https://github.com/hrbrmstr/hrbrthemes","commit_stats":{"total_commits":126,"total_committers":14,"mean_commits":9.0,"dds":0.1428571428571429,"last_synced_commit":"3e8d9494a9e0026a3127f6a0df88208511cd0715"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrbrmstr%2Fhrbrthemes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrbrmstr%2Fhrbrthemes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrbrmstr%2Fhrbrthemes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrbrmstr%2Fhrbrthemes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hrbrmstr","download_url":"https://codeload.github.com/hrbrmstr/hrbrthemes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254159182,"owners_count":22024558,"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":["data-visualization","datavisualization","ggplot-extension","ggplot2","ggplot2-scales","ggplot2-themes","r","rstats","visualization"],"created_at":"2024-07-31T05:00:23.784Z","updated_at":"2025-05-14T14:07:08.160Z","avatar_url":"https://github.com/hrbrmstr.png","language":"R","funding_links":["https://github.com/sponsors/hrbrmstr"],"categories":["2017","其他_机器学习与深度学习","R","Themes and aesthetics","Graphic Displays","ggplot"],"sub_categories":["Themes"],"readme":"\n\n[![Project Status: Active – The project has reached a stable, usable\nstate and is being actively\ndeveloped.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![Signed\nby](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keybase.io/hrbrmstr)\n![Signed commit\n%](https://img.shields.io/badge/Signed_Commits-8%25-lightgrey.svg)\n\n[![cran\nchecks](https://cranchecks.info/badges/worst/hrbrthemes.png)](https://cranchecks.info/pkgs/hrbrthemes)\n[![CRAN\nstatus](https://www.r-pkg.org/badges/version/hrbrthemes.png)](https://www.r-pkg.org/pkg/hrbrthemes)\n![Minimal R\nVersion](https://img.shields.io/badge/R%3E%3D-4.0.0-blue.svg)\n![License](https://img.shields.io/badge/License-MIT-blue.svg)\n![downloads](https://cranlogs.r-pkg.org/badges/grand-total/hrbrthemes.png)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2545422.svg)](https://doi.org/10.5281/zenodo.2545422)\n\n## hrbrthemes\n\nAdditional Themes and Theme Components for ‘ggplot2’\n\n------------------------------------------------------------------------\n\nThis is a very focused package that provides typography-centric themes\nand theme components for ggplot2.\n\nThe core theme: `theme_ipsum` (“ipsum” is Latin for “precise”) uses\nArial Narrow which should be installed on practically any modern system,\nso it’s “free”-ish. This font is condensed, has solid default kerning\npairs and geometric numbers. That’s what I consider the “font trifecta”\nmust-have for charts. An additional quality for fonts for charts is that\nthey have a diversity of weights. Arial Narrow (the one on most systems,\nanyway) does not have said diversity but this quality is not (IMO) a\n“must have”.\n\nThe following functions are implemented/objects are exported:\n\nThemes:\n\n- `theme_ipsum`: Arial Narrow\n- `theme_ipsum_gs`: Goldman Sans Condensed\n- `theme_ipsum_es`: Econ Sans Condensed\n- `theme_ipsum_rc`: Roboto Condensed\n- `theme_ipsum_ps`: IBM Plex Sans font\n- `theme_ipsum_pub`: Public Sans\n- `theme_ipsum_tw`: Titilium Web\n- `theme_modern_rc`: Roboto Condensed dark theme\n- `theme_ft_rc`: Dark theme based on FT’s dark theme (Roboto Condensed)\n\nScales (that align with various themes):\n\n- `scale_color_ipsum`: Discrete color \u0026 fill scales based on the ipsum\n  palette\n- `scale_colour_ipsum`: Discrete color \u0026 fill scales based on the ipsum\n  palette\n- `scale_fill_ipsum`: Discrete color \u0026 fill scales based on the ipsum\n  palette\n- `scale_color_ft`: Discrete color \u0026 fill scales based on the FT palette\n- `scale_colour_ft`: Discrete color \u0026 fill scales based on the FT\n  palette\n- `scale_fill_ft`: Discrete color \u0026 fill scales based on the FT palette\n- `scale_x_comma`: X \u0026 Y scales with opinionated presets for percent \u0026\n  comma label formats\n- `scale_x_percent`: X \u0026 Y scales with opinionated presets for percent \u0026\n  comma label formats\n- `scale_y_comma`: X \u0026 Y scales with opinionated presets for percent \u0026\n  comma label formats\n- `scale_y_percent`: X \u0026 Y scales with opinionated presets for percent \u0026\n  comma label formats\n\nPalettes/Named Colors:\n\n- `ipsum_pal`: A muted, qualitative color palette\n- `ft_cols`: FT color palette\n- `ft_pal`: A bright qualitative color palette\n- `ft_text_col`: FT color palette\n- `bit12`: A vector of 12 vibrant colors for categorical data\n- `bit12_extended`: List of 12 color palettes with 9 shades each for\n  continuous interpolation\n\nFonts:\n\n- `font_an`: Arial Narrow font name R variable aliases\n- `font_es`: Econ Sans font name R variable aliases\n- `font_es_bold`: Econ Sans font name R variable aliases\n- `font_es_light`: Econ Sans font name R variable aliases\n- `font_rc`: Roboto Condensed font name R variable aliases\n- `font_rc_light`: Roboto Condensed font name R variable aliases\n- `font_pub`: Public Sans font name R variable aliases\n- `font_pub_bold`: Public Sans font name R variable aliases\n- `font_pub_light`: Public Sans font name R variable aliases\n- `font_pub_thin`: Public Sans font name R variable aliases\n- `font_ps`: PlexSans font name R variable aliases\n- `font_ps_light`: PlexSans font name R variable aliases\n\nFlexoki Color Scales:\n\n- `scale_fill_flexoki_continuous`: Continuous Fill Scale Using Flexoki\n  Colors\n- `scale_fill_flexoki_dark`: Discrete Fill Scale Using Flexoki Dark\n  Colors\n- `scale_fill_flexoki_dark_distiller`: Distiller Fill Scale Using\n  Flexoki Dark Colors\n- `scale_fill_flexoki_dark_spectrum`: Distiller Fill Scale Across All\n  Flexoki Dark Colors\n- `scale_fill_flexoki_light`: Discrete Fill Scale Using Flexoki Light\n  Colors\n- `scale_fill_flexoki_light_distiller`: Distiller Fill Scale Using\n  Flexoki Light Colors\n- `scale_fill_flexoki_light_spectrum`: Distiller Fill Scale Across All\n  Flexoki Light Colors\n\nBit12 Color Scales:\n\n- `scale_color_bit12`: Discrete Color Scale Using Bit12 Colors\n- `scale_fill_bit12`: Discrete Fill Scale Using Bit12 Colors\n- `scale_color_bit12_continuous`: Continuous Color Scale Using Bit12\n  Colors\n- `scale_fill_bit12_continuous`: Continuous Fill Scale Using Bit12\n  Colors\n- `scale_color_bit12_distiller`: Distiller Color Scale Using Bit12\n  Colors\n- `scale_fill_bit12_distiller`: Distiller Fill Scale Using Bit12 Colors\n- `scale_color_bit12_spectrum`: Distiller Color Scale Across All Bit12\n  Colors\n- `scale_fill_bit12_spectrum`: Distiller Fill Scale Across All Bit12\n  Colors\n\nFlexoki Palettes:\n\n- `flexoki_light`: Vector of 8 colors in the light variant\n- `flexoki_dark`: Vector of 8 colors in the dark variant\n- `flexoki_extended`: List of 8 color palettes with 13 shades each for\n  continuous interpolation\n\nUtilities:\n\n- `flush_ticks`: Makes axis text labels flush on the ends\n- `ft_geom_defaults`: Change geom defaults from black to custom lights\n  for the FT theme\n- `gg_check`: Spell check ggplot2 plot labels\n- `import_econ_sans`: Import Econ Sans Condensed font for use in charts\n- `import_plex_sans`: Import IBM Plex Sans font for use in charts\n- `import_roboto_condensed`: Import Roboto Condensed font for use in\n  charts\n- `modern_geom_defaults`: Change geom defaults from black to white for\n  the modern theme\n- `update_geom_font_defaults`: Update matching font defaults for text\n  geoms\n\n### Installation\n\n``` r\ninstall.packages(\"hrbrthemes\") # NOTE: CRAN version is 0.8.7\n# or\nremotes::install_git(\"https://codeberg.org/hrbrmstr/hrbrthemes.git\")\n```\n\nNOTE: To use the ‘remotes’ install options you will need to have the\n[{remotes} package](https://github.com/r-lib/remotes) installed.\n\n### Usage\n\n``` r\nlibrary(hrbrthemes)\nlibrary(gcookbook)\nlibrary(tidyverse)\n\n# current version\npackageVersion(\"hrbrthemes\")\n## [1] '0.9.2'\n```\n\n### Base theme (Arial Narrow)\n\n``` r\nggplot(mtcars, aes(mpg, wt)) +\n  geom_point() +\n  labs(x=\"Fuel efficiency (mpg)\", y=\"Weight (tons)\",\n       title=\"Seminal ggplot2 scatterplot example\",\n       subtitle=\"A plot that is only useful for demonstration purposes\",\n       caption=\"Brought to you by the letter 'g'\") +\n  theme_ipsum()\n```\n\n\u003cimg src=\"man/figures/README-an-1.png\" width=\"672\" /\u003e\n\n### Roboto Condensed\n\n``` r\nggplot(mtcars, aes(mpg, wt)) +\n  geom_point() +\n  labs(x=\"Fuel efficiency (mpg)\", y=\"Weight (tons)\",\n       title=\"Seminal ggplot2 scatterplot example\",\n       subtitle=\"A plot that is only useful for demonstration purposes\",\n       caption=\"Brought to you by the letter 'g'\") +\n  theme_ipsum_rc()\n```\n\n\u003cimg src=\"man/figures/README-rc-1.png\" width=\"672\" /\u003e\n\n### New FT Theme!\n\n``` r\nggplot(mtcars, aes(mpg, wt)) +\n  geom_point(color = ft_cols$yellow) +\n  labs(x=\"Fuel efficiency (mpg)\", y=\"Weight (tons)\",\n       title=\"Seminal ggplot2 scatterplot example\",\n       subtitle=\"A plot that is only useful for demonstration purposes\",\n       caption=\"Brought to you by the letter 'g'\") +\n  theme_ft_rc()\n```\n\n\u003cimg src=\"man/figures/README-ft-1.png\" width=\"672\" /\u003e\n\n### IBM Plex Sans\n\n``` r\nggplot(mpg, aes(displ, hwy)) +\n  geom_jitter(aes(color=class, fill=class), size=3, shape=21, alpha=1/2) +\n  scale_x_continuous(expand=c(0,0), limits=c(1, 8), breaks=1:8) +\n  scale_y_continuous(expand=c(0,0), limits=c(10, 50)) +\n  scale_color_ipsum() +\n  scale_fill_ipsum() +\n  facet_wrap(~class, scales=\"free\") +\n  labs(\n    title=\"IBM Plex Sans Test\",\n    subtitle=\"This is a subtitle to see the how it looks in IBM Plex Sans\",\n    caption=\"Source: hrbrthemes \u0026 IBM\"\n  ) +\n  theme_ipsum_ps(grid=\"XY\", axis=\"xy\") +\n  theme(legend.position=\"none\") -\u003e gg\n\nflush_ticks(gg)\n## theme(axis.text.x=element_text(hjust=c(0, rep(0.5, 6), 1))) +\n## theme(axis.text.y=element_text(vjust=c(0, rep(0.5, 3), 1)))\n```\n\n\u003cimg src=\"man/figures/README-ps-1.png\" width=\"960\" /\u003e\n\n### Scales (Color/Fill)\n\n``` r\nggplot(mtcars, aes(mpg, wt)) +\n  geom_point(aes(color=factor(carb))) +\n  labs(x=\"Fuel efficiency (mpg)\", y=\"Weight (tons)\",\n       title=\"Seminal ggplot2 scatterplot example\",\n       subtitle=\"A plot that is only useful for demonstration purposes\",\n       caption=\"Brought to you by the letter 'g'\") +\n  scale_color_ipsum() +\n  theme_ipsum_rc()\n```\n\n\u003cimg src=\"man/figures/README-sc-1.png\" width=\"672\" /\u003e\n\n### Scales (Axis)\n\n``` r\ncount(mpg, class) %\u003e%\n  mutate(pct=n/sum(n)) %\u003e%\n  ggplot(aes(class, pct)) +\n  geom_col() +\n  scale_y_percent() +\n  labs(x=\"Fuel efficiency (mpg)\", y=\"Weight (tons)\",\n       title=\"Seminal ggplot2 column chart example with percents\",\n       subtitle=\"A plot that is only useful for demonstration purposes\",\n       caption=\"Brought to you by the letter 'g'\") +\n  theme_ipsum(grid=\"Y\")\n```\n\n\u003cimg src=\"man/figures/README-ax1-1.png\" width=\"672\" /\u003e\n\n``` r\nggplot(uspopage, aes(x=Year, y=Thousands, fill=AgeGroup)) +\n  geom_area() +\n  scale_fill_ipsum() +\n  scale_x_continuous(expand=c(0,0)) +\n  scale_y_comma() +\n  labs(title=\"Age distribution of population in the U.S., 1900-2002\",\n       subtitle=\"Example data from the R Graphics Cookbook\",\n       caption=\"Source: R Graphics Cookbook\") +\n  theme_ipsum_rc(grid=\"XY\") +\n  theme(axis.text.x=element_text(hjust=c(0, 0.5, 0.5, 0.5, 1))) +\n  theme(legend.position=\"bottom\")\n```\n\n\u003cimg src=\"man/figures/README-ax2-1.png\" width=\"672\" /\u003e\n\n``` r\nupdate_geom_font_defaults(font_rc_light)\n\ncount(mpg, class) %\u003e%\n  mutate(n=n*2000) %\u003e%\n  arrange(n) %\u003e%\n  mutate(class=factor(class, levels=class)) %\u003e%\n  ggplot(aes(class, n)) +\n  geom_col() +\n  geom_text(aes(label=scales::comma(n)), hjust=0, nudge_y=2000) +\n  scale_y_comma(limits=c(0,150000)) +\n  coord_flip() +\n  labs(x=\"Fuel efficiency (mpg)\", y=\"Weight (tons)\",\n       title=\"Seminal ggplot2 column chart example with commas\",\n       subtitle=\"A plot that is only useful for demonstration purposes, esp since you'd never\\nreally want direct labels and axis labels\",\n       caption=\"Brought to you by the letter 'g'\") +\n  theme_ipsum_rc(grid=\"X\")\n```\n\n\u003cimg src=\"man/figures/README-ax3-1.png\" width=\"672\" /\u003e\n\n### Spellcheck ggplot2 labels\n\n``` r\ndf \u003c- data.frame(x=c(20, 25, 30), y=c(4, 4, 4), txt=c(\"One\", \"Two\", \"Three\"))\n\nggplot(mtcars, aes(mpg, wt)) +\n  geom_point() +\n  labs(x=\"This is some txt\", y=\"This is more text\",\n       title=\"Thisy is a titlle\",\n       subtitle=\"This is a subtitley\",\n       caption=\"This is a captien\") +\n  theme_ipsum_rc(grid=\"XY\") -\u003e gg\n\ngg_check(gg)\n## Possible misspelled words in [title]: (Thisy, titlle)\n## Possible misspelled words in [subtitle]: (subtitley)\n## Possible misspelled words in [caption]: (captien)\n```\n\n\u003cimg src=\"man/figures/README-sp-1.png\" width=\"672\" /\u003e\n\n### Flexoki Color Scales\n\nThe Flexoki color system provides both discrete and continuous color\nscales in light and dark variants.\n\n``` r\n# Discrete colors example with light variant\nggplot(mpg, aes(class, fill=class)) +\n  geom_bar() +\n  labs(title=\"Flexoki Light Colors\",\n       subtitle=\"Discrete color scale example\",\n       caption=\"Using scale_fill_flexoki_light()\") +\n  theme_ipsum() +\n  scale_fill_flexoki_light() +\n  theme(legend.position=\"none\")\n```\n\n\u003cimg src=\"man/figures/README-flexoki1-1.png\" width=\"672\" /\u003e\n\n``` r\n# Dark variant with points\nggplot(mpg, aes(displ, hwy, color=class)) +\n  geom_point(size=3) +\n  labs(title=\"Flexoki Dark Colors\",\n       subtitle=\"Another discrete color example\",\n       caption=\"Using scale_color_flexoki_dark()\") +\n  theme_ipsum_rc() +\n  scale_color_flexoki_dark()\n```\n\n\u003cimg src=\"man/figures/README-flexoki2-1.png\" width=\"672\" /\u003e\n\n``` r\nlibrary(patchwork)\n\ndata.frame(\n  x = rep(1:50, 50),\n  y = rep(1:50, each=50),\n  z = sqrt((rep(1:50, 50)-25)^2 + (rep(1:50, each=50)-25)^2)\n) -\u003e grad_df\n\nnames(flexoki_dark) |\u003e \n  map(\\(.p) {\n    ggplot(grad_df, aes(x, y, fill=z)) +\n      geom_tile() +\n      scale_fill_flexoki_continuous(palette = .p) +\n      labs(\n        x = NULL, y = NULL\n      ) +\n      theme_ipsum(grid=\"\") +\n      theme(legend.position = \"none\")\n  }) |\u003e \n  do.call(what = \"wrap_plots\") +\n  plot_layout(ncol = 4) +\n  plot_annotation(\n    title=\"Flexoki Continuous Color Scales\",\n    subtitle=\"All 8 continuous color palettes\",\n    caption=\"Using scale_fill_flexoki_continuous()\",\n    theme = theme_ipsum(grid=\"\")\n  )\n```\n\n\u003cimg src=\"man/figures/README-flexoki-03-1.png\" width=\"960\" /\u003e\n\n### Bit12 Color Scales\n\nThe Bit12 color system provides a set of 12 distinct colors optimized\nfor data visualization.\n\n``` r\n# Discrete colors example\nggplot(mpg, aes(class, fill=class)) +\n  geom_bar() +\n  labs(title=\"Bit12 Color Palette\",\n       subtitle=\"A vibrant 12-color categorical palette\",\n       caption=\"Using scale_fill_bit12()\") +\n  theme_ipsum() +\n  scale_fill_bit12() +\n  theme(legend.position=\"none\")\n```\n\n\u003cimg src=\"man/figures/README-bit12-01-1.png\" width=\"672\" /\u003e\n\n``` r\nlibrary(patchwork)\n\n# Taking a subset of the palette for this example\nnames(bit12)[c(1,3,5,7,9,11)] |\u003e \n  map(\\(.p) {\n    ggplot(grad_df, aes(x, y, fill=z)) +\n      geom_tile() +\n      scale_fill_bit12_continuous(palette = .p) +\n      labs(\n        x = NULL, y = NULL, title = .p\n      ) +\n      theme_ipsum(grid=\"\") +\n      theme(legend.position = \"none\")\n  }) |\u003e \n  do.call(what = \"wrap_plots\") +\n  plot_layout(ncol = 3) +\n  plot_annotation(\n    title=\"Bit12 Continuous Color Scales\",\n    subtitle=\"Selected continuous color palettes\",\n    caption=\"Using scale_fill_bit12_continuous()\",\n    theme = theme_ipsum(grid=\"\")\n  )\n```\n\n\u003cimg src=\"man/figures/README-bit12-02-1.png\" width=\"960\" /\u003e\n\n### hrbrthemes Metrics\n\n| Lang | \\# Files |  (%) |  LoC |  (%) | Blank lines | (%) | \\# Lines | (%) |\n|:-----|---------:|-----:|-----:|-----:|------------:|----:|---------:|----:|\n| R    |       23 | 0.44 | 1840 | 0.46 |         339 | 0.5 |     1290 | 0.5 |\n| SVG  |        2 | 0.04 |  150 | 0.04 |           0 | 0.0 |        0 | 0.0 |\n| JSON |        1 | 0.02 |   15 | 0.00 |           0 | 0.0 |        0 | 0.0 |\n| SUM  |       26 | 0.50 | 2005 | 0.50 |         339 | 0.5 |     1290 | 0.5 |\n\n{cloc} 📦 metrics for hrbrthemes\n\n### Code of Conduct\n\nPlease note that this project is released with a Contributor Code of\nConduct. By participating in this project you agree to abide by its\nterms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhrbrmstr%2Fhrbrthemes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhrbrmstr%2Fhrbrthemes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhrbrmstr%2Fhrbrthemes/lists"}