Package 'stevethemes'

Title: Steve's 'ggplot2' Themes and Related Theme Elements
Description: This is a compilation of my preferred themes and related theme elements for 'ggplot2'. I believe these themes and theme elements are aesthetically pleasing, both for pedagogical instruction and for the presentation of applied statistical research to a wide audience. These themes imply routine use of easily obtained/free fonts, simple forms of which are included in this package.
Authors: Steve Miller [aut, cre] , Accademia di Belle Arti di Urbino [ctb] (Principal design of Titillium Web font), Steve Matteson [ctb] (Designer of Open Sans), Erik Spiekermann [ctb] (Designer of Fira Sans), Ralph du Carrois [ctb] (Designer of Fira Sans), Sebastian Kosch [ctb] (Design initiator for Crimson Pro), Jacques Le Bailly [ctb] (Designer of Crimson Pro), Eben Sorkin [ctb] (Designer of Merriweather)
Maintainer: Steve Miller <[email protected]>
License: MIT + file LICENSE
Version: 0.1.9
Built: 2024-11-17 03:39:37 UTC
Source: https://github.com/svmiller/stevethemes

Help Index


Miscellaneous functions for fine-tuning ggplot2 plots

Description

These are assorted functions that will fine-tune various things in a ggplot2 plot.

Usage

adj_font_size(x, ...)

Arguments

x

a numeric vector that will adjust the size of all fonts on the plot. Can take decimals and negative numbers.

...

optional, called for side effects

Details

adj_font_size() is a simple wrapper for some basic ggplot2 code that will allow you to adjust the font size on the plot by some number.

Right now, adj_font_size() assumes you are using theme_steve() because the font sizes initialized in the function are defaults from the theme.

Value

adj_font_size() takes a plot made in ggplot2 and changes the font size by some number requested by the user. It returns a plot with bigger or smaller fonts, per the user's request.

Author(s)

Steven V. Miller

Examples

library(ggplot2)

example_plot(type = "scatter") + adj_font_size(-2)

example_plot(type = "scatter") + adj_font_size(2)

Check if you have the fonts you need already installed on your computer

Description

are_fonts_installed() leans on systemfonts to determine if R can find the fonts that are used by the stevethemes package.

Usage

are_fonts_installed(check = "all")

Arguments

check

a character vector coinciding with the font or fonts you want to check. Defaults to "all", which will check for all of "Open Sans", "Titillium Web", "Fira Sans", "Crimson Pro", and "Merriweather".

Details

Future functionality will allow you to supply more than "all", but "all" is the only argument for the function that will work for the moment.

Value

are_fonts_installed() returns a message communicating whether the systemfonts package in R can find the fonts used by stevethemes on the user's operating system. It also returns some information about where the user can download or obtain these fonts.

Author(s)

Steven V. Miller

Examples

are_fonts_installed()

Create an example plot (in ggplot2) for experimenting with different styles

Description

example_plot() allows you to experiment with some ggplot2 themes, like those in this package, by seeing them applied to some example plots.

Usage

example_plot(type = "bar")

Arguments

type

a type

Details

I'll add more here in a little bit.

Value

example_plot() returns a plot made in ggplot2, allowing the user to experiment with different themes to see which ones they like the best.

Author(s)

Steven V. Miller

Examples

library(ggplot2)

example_plot()

example_plot(type = "faceted_line")

example_plot(type = "scatter")

Get a Custom Color from steve_hex

Description

g_c() (i.e. *g*et *c*olor) is a simple function that interfaces with the steve_hex data frame to return a hex value associated with a named color.

Usage

g_c(x)

Arguments

x

a label coinciding with a value in the color column of the steve_hex data frame

Details

Check steve_hex in this same package for the custom colors included

Value

g_c() returns a character vector, in particular, a hex triplet that coincides with the label supplied in the function. Use it for specifying a custom fill or color in a plot.

Author(s)

Steven V. Miller

Examples

g_c("su_blue")

g_c("martel_pink")

Learn how to install fonts on your computer

Description

how_to_install_fonts() communicates to the user how they can install fonts on their computer.

Usage

how_to_install_fonts(os = "any")

Arguments

os

a character vector coinciding with the information you want, contingent on your operating system. If os is "any" (the default), it returns a generic message about how to install fonts. If os is "windows", "mac", or "linux", you get more information about font installation on your operating system.

Details

The 'any' option for the os argument is necessarily less informative. If you know whether you're using Windows, a Mac, or Linux, you should change the os argument.

Value

how_to_install_fonts() returns a message communicating how to install fonts on the user's operating system.

Author(s)

Steven V. Miller

Examples

how_to_install_fonts("windows")

how_to_install_fonts("mac")

Kilowatt Hours per Capita and GDP per Capita, 2010

Description

This is a simple data frame of the GDP per capita and kilowatt hours consumed per capita of over 130 sovereign states in 2010.

Usage

kwh_gdp

Format

A data frame the following 7 variables.

country

the name of the country

iso3c

the three-character ISO code of the country

year

the year of observation (2010)

kwhpc

the electric power consumption (kilowatt hours) per capita of the country

gdppc

the GDP per capita of the country in current USD

ln_kwhpc

the (log-transformed) electric power consumption (kilowatt hours) per capita of the country

ln_gdppc

the (log-transformed) GDP per capita of the country in current USD

Details

Data come from a use of the WDI() function in the WDI package. The GDP per capita data come from a combination of the World Bank and OECD. The energy consumption data come from the International Energy Agency. Data exist to be used in a simple scatterplot.


CAGEMATCH Ratings of Rick Martel

Description

This is a simple data frame of ratings (on a 1-10 scale) of Rick Martel.

Usage

martel_ratings

Format

A data frame the following 2 variables.

date

a date vector for when the rating was posted on CAGEMATCH

value

an individual person's rating of Rick Martel (on a 1-10 scale)

Details

Data exist to be used an example bar chart. CAGEMATCH (stylized in all caps) is an internet wrestling database, for which these ratings are fan submissions. Rick Martel is an objective 10/10.


GDP per Capita of Swedish Counties, 2001-2020

Description

This is a simple data frame of the GDP per capita of Swedish counties from 2001 to 2020.

Usage

se_counties_gdppc

Format

A data frame the following 4 variables.

nuts

the Nomenclature of Territorial Units for Statistics (NUTS) code for the county

county

the name of the county

year

the year of observation

value

the GDP per capita of the county in nominal SEK

Details

Data come from the OECD and exist to be used as a faceted line chart.


Some Hex Triplets I Find Useful/Interesting/Fun

Description

This is a simple data frame with labels corresponding to hex triplets (i.e. web colors) that I find useful, interesting, or fun.

Usage

steve_hex

Format

A data frame the following 2 variables.

color

a character vector describing the color in question

hex

a hex triplet (with preceding hashtag) of the color

Details

Data exist to be used by g_c() in this same package.


Steve's Preferred ggplot2 Theme

Description

theme_steve() is my default theme framework for graphs I make with ggplot2. It starts theme_bw(), which is available in ggplot2, but adjusts the margins and axes a bit to my liking. The end result is, I think, a lovely template for graphs I make in R.

Usage

theme_steve(style = "web", font, ...)

Arguments

style

various styles/adjustments to make to the base theme. Must be one of the following: "web" (default), "ms", "fira", "merri", "custom", or "generic". The "custom" style is a fancy way of saying "supply your own fonts". Where "custom" is used in this argument, something must be supplied to the font argument in this same function.

font

a character vector corresponding with a font that the user ideally has installed on their operating system.

...

optional, called for side effects

Details

The best use of this function may involve the fonts you have installed on your system. The user should experiment with various options to see what they like. The "generic" style will use default ggplot2 fonts and is invoked here in this simple function for CRAN testing requirements. The default is "web", which depends on having Open Sans and Titillium Web on the operating system. You will see these two fonts everywhere on my website and most of my R package websites.

For greater clarity, the user should understand "ms" is code for the Crimson Pro font, which resembles the "cochineal" font family in the LaTeX font catalogue. "cochineal" is a fork of the Crimson font and its use is heavily implied by my preferred article template ('article2') in stevetemplates.

"fira" is shorthand for "Fira Sans". "merri" is shorthand for "Merriweather". The former features prominently in Firefox as well as my current operating system (Pop! OS). The latter incorporates the Merriweather font, which is a close cousin of the Palatino font. Palatino is the implied default font of my first article template ('article') in stevetemplates.

Value

No return value. Function is used for its side effect, which is to format a plot made in the ggplot2 package.

Examples

library(ggplot2)

# Experiment with options, those this depends on fonts you have installed.
example_plot() + theme_steve(style='generic')