https://github.com/sportsdataverse/cfbplotR
A set of functions to visualize college football teams in 'ggplot2'
https://github.com/sportsdataverse/cfbplotR
college-football ggplot2 r rstats sportsdataverse
Last synced: 4 months ago
JSON representation
A set of functions to visualize college football teams in 'ggplot2'
- Host: GitHub
- URL: https://github.com/sportsdataverse/cfbplotR
- Owner: sportsdataverse
- License: other
- Created: 2021-09-08T04:00:36.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-29T00:47:16.000Z (over 1 year ago)
- Last Synced: 2024-12-01T13:35:51.617Z (4 months ago)
- Topics: college-football, ggplot2, r, rstats, sportsdataverse
- Language: R
- Homepage: https://cfbplotR.sportsdataverse.org
- Size: 81.7 MB
- Stars: 9
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - sportsdataverse/cfbplotR - A set of functions to visualize college football teams in 'ggplot2' (R)
README
---
output: github_document
---```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```[](https://github.com/sportsdataverse/cfbplotR/)
[](https://github.com/sportsdataverse/cfbplotR/actions/workflows/R-CMD-check.yaml)
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)[](https://github.com/sportsdataverse/cfbplotR/graphs/contributors)
[](https://twitter.com/JaredDLee)
[](https://twitter.com/SportsDataverse)The code for this package was copied heavily from [nflplotR](https://nflplotr.nflverse.com/index.html) with minor changes to support college football team logos.
The goal of `cfbplotR` is to provide functions and geoms that help visualization of CFB related analysis. It provides a ggplot2 geom that does the heavy lifting of plotting CFB logos in high quality, with correct aspect ratio and possible transparency.
## Installation
You can install the development version from [GitHub](https://github.com/) with:
``` r
if (!require("remotes")) install.packages("remotes")
remotes::install_github("sportsdataverse/cfbplotR")
```## Using cfbplotR
[You can follow this tutorial to see several different uses for `cfbplotR`.](https://cfbplotR.sportsdataverse.org/articles/tutorial.html) The key function in the package is `geom_cfb_logo()` which will add college football team logos to a ggplot.
```{r example, dpi=300}
library(cfbplotR)
library(ggplot2)
team <- valid_team_names()
team <- team[1:32]
df <- data.frame(
a = rep(1:8, 4),
b = sort(rep(1:4, 8), decreasing = TRUE),
teams = team
)# keep alpha == 1 for all teams including an "A"
matches <- grepl("A", team)
df$alpha <- ifelse(matches, 1, 0.9)
# change color of all teams including an "o" to black and white
matches <- grepl("o", team)
df$color <- ifelse(matches, "b/w", NA)ggplot(df, aes(x = a, y = b)) +
geom_cfb_logos(aes(team = teams, color = color, alpha = alpha), width = 0.075) +
geom_label(aes(label = teams), nudge_y = -0.35, alpha = 0.5) +
scale_color_identity() +
scale_alpha_identity() +
theme_void()
```## Getting help
The best places to get help on this package are:
- messaging [Jared Lee on twitter](https://twitter.com/JaredDLee)
- opening [an issue](https://github.com/sportsdataverse/cfbplotR/issues/new/choose)## Contributing
Many hands make light work! Here are some ways you can contribute to
this project:- You can [open an issue](https://github.com/sportsdataverse/cfbplotR/issues/new/choose) if you’d like to request specific data or report a bug/error.
## Terms of Use
The R code for this package is released as open source under the [MIT License](https://cfbplotR.sportsdataverse.org/LICENSE.html). CFB data accessed by this package belong to their respective owners, and are governed by their terms of use.
## Follow [cfbfastR](https://twitter.com/cfbfastR) and the [SportsDataverse](https://twitter.com/SportsDataverse) on Twitter and star this repo
[](https://twitter.com/cfbfastR)
[](https://twitter.com/SportsDataverse)
[](https://github.com/sportsdataverse/cfbplotR/stargazers/)
## **Our Authors**
- [Jared Lee](https://twitter.com/JaredDLee)
![]()
- [Sebastian Carl](https://twitter.com/mrcaseb)
![]()
## **Our Contributors (they're awesome)**
- [Saiem Gilani](https://twitter.com/saiemgilani)
![]()
## **Citations**
To cite the [**`cfbplotR`**](https://cfbplotR.sportsdataverse.org/) R package in publications, use:
BibTex Citation
```bibtex
@misc{lee_carl_2021_cfbplotr,
author = {Jared Lee and Sebastian Carl},
title = {cfbplotR: The SportsDataverse's R Package for College Football Plotting.},
url = {https://cfbplotR.sportsdataverse.org/},
year = {2021}
}
```