R語言繪圖-擴充套件包hrbrthemes

Themes:theme_ipsum: Arial Narrowtheme_ipsum_gs: Goldman Sans Condensedtheme_ipsum_es: Econ Sans Condensedtheme_ipsum_rc: Roboto Condensedtheme_ipsum_ps: IBM Plex Sans fonttheme_ipsum_pub: Public Sanstheme_ipsum_tw: Titilium Webtheme_modern_rc: Roboto Condensed dark themetheme_ft_rc: Dark theme based on FT’s dark theme (Roboto Condensed)Scales (that align with various themes):scale_color_ipsum: Discrete color & fill scales based on the ipsum palettescale_colour_ipsum: Discrete color & fill scales based on the ipsum palettescale_fill_ipsum: Discrete color & fill scales based on the ipsum palettescale_color_ft: Discrete color & fill scales based on the FT palettescale_colour_ft: Discrete color & fill scales based on the FT palettescale_fill_ft: Discrete color & fill scales based on the FT palettescale_x_comma: X & Y scales with opinionated presets for percent & comma label formatsscale_x_percent: X & Y scales with opinionated presets for percent & comma label formatsscale_y_comma: X & Y scales with opinionated presets for percent & comma label formatsscale_y_percent: X & Y scales with opinionated presets for percent & comma label formatsPalettes/Named Colors:ipsum_pal: A muted, qualitative color paletteft_cols: FT color paletteft_pal: A bright qualitative color paletteft_text_col: FT color paletteFonts:font_an: Arial Narrow font name R variable aliasesfont_es: Econ Sans font name R variable aliasesfont_es_bold: Econ Sans font name R variable aliasesfont_es_light: Econ Sans font name R variable aliasesfont_rc: Roboto Condensed font name R variable aliasesfont_rc_light: Roboto Condensed font name R variable aliasesfont_pub: Public Sans font name R variable aliasesfont_pub_bold: Public Sans font name R variable aliasesfont_pub_light: Public Sans font name R variable aliasesfont_pub_thin: Public Sans font name R variable aliasesfont_ps: PlexSans font name R variable aliasesfont_ps_light: PlexSans font name R variable aliasesfont_tw: Titillium Web font name R variable aliasesfont_tw_bold: Titillium Web font name R variable aliasesfont_tw_light: Titillium Web font name R variable aliasesR Markdown:ipsum: ipsum R markdown templateipsum_pdf: ipsum R markdown template for PDF outputUtilities:flush_ticks: Makes axis text labels flush on the endsft_geom_defaults: Change geom defaults from black to custom lights for the FT themegg_check: Spell check ggplot2 plot labelsimport_econ_sans: Import Econ Sans Condensed font for use in chartsimport_plex_sans: Import IBM Plex Sans font for use in chartsimport_roboto_condensed: Import Roboto Condensed font for use in chartsimport_titillium_web: Import Titillium Web font for use in chartsmodern_geom_defaults: Change geom defaults from black to white for the modern themeupdate_geom_font_defaults: Update matching font defaults for text geoms

Base theme (Arial Narrow)

ggplot(mtcars, aes(mpg, wt)) + geom_point() + labs(x=“Fuel efficiency (mpg)”, y=“Weight (tons)”, title=“Seminal ggplot2 scatterplot example”, subtitle=“A plot that is only useful for demonstration purposes”, caption=“Brought to you by the letter ‘g’”) + theme_ipsum()

R語言繪圖-擴充套件包hrbrthemes

Roboto Condensed

ggplot(mtcars, aes(mpg, wt)) + geom_point() + labs(x=“Fuel efficiency (mpg)”, y=“Weight (tons)”, title=“Seminal ggplot2 scatterplot example”, subtitle=“A plot that is only useful for demonstration purposes”, caption=“Brought to you by the letter ‘g’”) + theme_ipsum_rc()

R語言繪圖-擴充套件包hrbrthemes

New FT Theme!

ggplot(mtcars, aes(mpg, wt)) + geom_point(color = ft_cols$yellow) + labs(x=“Fuel efficiency (mpg)”, y=“Weight (tons)”, title=“Seminal ggplot2 scatterplot example”, subtitle=“A plot that is only useful for demonstration purposes”, caption=“Brought to you by the letter ‘g’”) + theme_ft_rc()

R語言繪圖-擴充套件包hrbrthemes

IBM Plex Sans

ggplot(mpg, aes(displ, hwy)) + geom_jitter(aes(color=class, fill=class), size=3, shape=21, alpha=1/2) + scale_x_continuous(expand=c(0,0), limits=c(1, 8), breaks=1:8) + scale_y_continuous(expand=c(0,0), limits=c(10, 50)) + scale_color_ipsum() + scale_fill_ipsum() + facet_wrap(~class, scales=“free”) + labs( title=“IBM Plex Sans Test”, subtitle=“This is a subtitle to see the how it looks in IBM Plex Sans”, caption=“Source: hrbrthemes & IBM” ) + theme_ipsum_ps(grid=“XY”, axis=“xy”) + theme(legend。position=“none”) -> ggflush_ticks(gg)## theme(axis。text。x=element_text(hjust=c(0, rep(0。5, 6), 1))) +## theme(axis。text。y=element_text(vjust=c(0, rep(0。5, 3), 1)))

R語言繪圖-擴充套件包hrbrthemes

Titillium Web

ggplot(mpg, aes(displ, hwy)) + geom_jitter(aes(color=class, fill=class), size=3, shape=21, alpha=1/2) + scale_x_continuous(expand=c(0,0), limits=c(1, 8), breaks=1:8) + scale_y_continuous(expand=c(0,0), limits=c(10, 50)) + scale_color_ipsum() + scale_fill_ipsum() + facet_wrap(~class, scales=“free”) + labs( title=“Titillium Web”, subtitle=“This is a subtitle to see the how it looks in Titillium Web”, caption=“Source: hrbrthemes & Google” ) + theme_ipsum_tw(grid=“XY”, axis=“xy”) + theme(legend。position=“none”) -> ggflush_ticks(gg)## theme(axis。text。x=element_text(hjust=c(0, rep(0。5, 6), 1))) +## theme(axis。text。y=element_text(vjust=c(0, rep(0。5, 3), 1)))

R語言繪圖-擴充套件包hrbrthemes

Scales (Color/Fill)

ggplot(mtcars, aes(mpg, wt)) + geom_point(aes(color=factor(carb))) + labs(x=“Fuel efficiency (mpg)”, y=“Weight (tons)”, title=“Seminal ggplot2 scatterplot example”, subtitle=“A plot that is only useful for demonstration purposes”, caption=“Brought to you by the letter ‘g’”) + scale_color_ipsum() + theme_ipsum_rc()

R語言繪圖-擴充套件包hrbrthemes

Scales (Axis)

count(mpg, class) %>% mutate(pct=n/sum(n)) %>% ggplot(aes(class, pct)) + geom_col() + scale_y_percent() + labs(x=“Fuel efficiency (mpg)”, y=“Weight (tons)”, title=“Seminal ggplot2 column chart example with percents”, subtitle=“A plot that is only useful for demonstration purposes”, caption=“Brought to you by the letter ‘g’”) + theme_ipsum(grid=“Y”)

R語言繪圖-擴充套件包hrbrthemes

update_geom_font_defaults(font_rc_light)count(mpg, class) %>% mutate(n=n*2000) %>% arrange(n) %>% mutate(class=factor(class, levels=class)) %>% ggplot(aes(class, n)) + geom_col() + geom_text(aes(label=scales::comma(n)), hjust=0, nudge_y=2000) + scale_y_comma(limits=c(0,150000)) + coord_flip() + labs(x=“Fuel efficiency (mpg)”, y=“Weight (tons)”, title=“Seminal ggplot2 column chart example with commas”, subtitle=“A plot that is only useful for demonstration purposes, esp since you‘d never\nreally want direct labels and axis labels”, caption=“Brought to you by the letter ’g‘”) + theme_ipsum_rc(grid=“X”)

update_geom_font_defaults(font_rc_light)count(mpg, class) %>% mutate(n=n*2000) %>% arrange(n) %>% mutate(class=factor(class, levels=class)) %>% ggplot(aes(class, n)) + geom_col() + geom_text(aes(label=scales::comma(n)), hjust=0, nudge_y=2000) + scale_y_comma(limits=c(0,150000)) + coord_flip() + labs(x=“Fuel efficiency (mpg)”, y=“Weight (tons)”, title=“Seminal ggplot2 column chart example with commas”, subtitle=“A plot that is only useful for demonstration purposes, esp since you’d never\nreally want direct labels and axis labels”, caption=“Brought to you by the letter ‘g’”) + theme_ipsum_rc(grid=“X”)

R語言繪圖-擴充套件包hrbrthemes

Spellcheck ggplot2 labels

df <- data。frame(x=c(20, 25, 30), y=c(4, 4, 4), txt=c(“One”, “Two”, “Three”))ggplot(mtcars, aes(mpg, wt)) + geom_point() + labs(x=“This is some txt”, y=“This is more text”, title=“Thisy is a titlle”, subtitle=“This is a subtitley”, caption=“This is a captien”) + theme_ipsum_rc(grid=“XY”) -> gggg_check(gg)## Possible misspelled words in [title]: (Thisy, titlle)## Possible misspelled words in [subtitle]: (subtitley)## Possible misspelled words in [caption]: (captien)