Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sarah's theme #40

Merged
merged 19 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Suggests:
ggtext,
here,
hexSticker,
hrbrthemes,
knitr,
purrr,
readr,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export(pool_taxon_counts)
export(read_dist)
export(read_tax)
export(set_knitr_opts)
export(theme_lucas)
export(theme_sovacool)
importFrom(dplyr,"%>%")
importFrom(formatR,tidy_source)
importFrom(rlang,.data)
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
taxonomic resolutions, as seen in <https://doi.org/10.1128/mbio.03161-21>
(#37, @kelly-sovacool).
- New function `calc_relabun()` calculates OTU relative abundances (#38, @kelly-sovacool).
- New custom themes for ggplot2:
- `theme_sovacool()` (#39, @kelly-sovacool)
- `theme_lucas()` (#40, @sklucas)

# schtools 0.2.1

Expand Down
74 changes: 74 additions & 0 deletions R/plot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#' Kelly's go-to theme for ggplot2
#'
#' Uses `ggplot2::theme_bw()` and removes margins.
#'
#' @return list of ggproto objects
#'
#' @export
#' @author Kelly Sovacool \email{sovacool@@umich.edu}
#'
#' @examples
#' library(ggplot2)
#' ggplot(mtcars) +
#' aes(x = mpg, y = wt, color = cyl) +
#' geom_point() +
#' theme_sovacool()
theme_sovacool <- function() {
return(list(
ggplot2::theme_bw(),
ggplot2::theme(
legend.margin = ggplot2::margin(0, 0, 0, 0, unit = "pt"),
legend.box.margin = ggplot2::margin(0, 0, 0, 0, unit = "pt"),
plot.margin = ggplot2::margin(0, 0, 0, 0, unit = "pt")
)
))
}
#' Sarah's go-to theme for ggplot2
#'
#' Requires the `hrbrthemes` package and the `PT Sans` and `PT Sans Narrow`
#' fonts from Google Fonts.
#'
#' @return list of ggproto objects
#' @export
#' @author Sarah Lucas \email{salucas@@umich.edu}
#'
#' @examples
#' library(ggplot2)
#' library(showtext)
#'
#' # run once to download the PT Sans fonts
#' font_add_google(name = "PT Sans", family = "PT Sans")
#' font_add_google(name = "PT Sans Narrow", family = "PT Sans Narrow")
#' showtext_auto()
#'
#' # make a plot with theme_lucas()
#' ggplot(mtcars) +
#' aes(x = mpg, y = wt, color = cyl) +
#' geom_point() +
#' theme_lucas()
theme_lucas <- function() {
return(list(
hrbrthemes::theme_ipsum(
base_family = "PT Sans",
base_size = 20,
axis_title_family = "PT Sans Narrow",
axis_title_size = 20,
axis_text_size = 16,
axis_title_just = "c"
),
ggplot2::theme(
plot.title = ggplot2::element_text(hjust = 0.5),
plot.subtitle = ggplot2::element_text(hjust = 0.5),
plot.margin = ggplot2::margin(15, 15, 15, 15),
panel.grid.minor = ggplot2::element_blank(),
panel.background = ggplot2::element_blank(),
legend.position = "bottom",
legend.key = ggplot2::element_rect(
fill = "white", color = "white", size = 4),
legend.key.width = ggplot2::unit(2, "cm"),
legend.text = ggplot2::element_text(size = 12),
plot.caption = ggplot2::element_text(
color = "#85919b", hjust = 0, size = 12, face = "plain")
)
))
}
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,25 @@ license](https://github.com/SchlossLab/schtools/blob/main/LICENSE.md#creative-co

To cite schtools in publications, use:

>
>
> <p>
>
> Sovacool K, Lesniak N, Schloss P (2022). <em>schtools: Schloss Lab
> Tools for Reproducible Microbiome Research</em>. R package version
> 0.2.1,
> <a href="https://CRAN.R-project.org/package=schtools">https://CRAN.R-project.org/package=schtools</a>.
> Tools for Reproducible Microbiome Research</em>.
> <http://www.schlosslab.org/schtools/>,
> <https://github.com/SchlossLab/schtools>.
>
> </p>

A BibTeX entry for LaTeX users is:

@Manual{,
title = {schtools: Schloss Lab Tools for Reproducible Microbiome Research},
author = {Kelly Sovacool and Nick Lesniak and Patrick Schloss},
year = {2022},
note = {R package version 0.2.1},
url = {https://CRAN.R-project.org/package=schtools},
}
```
@Manual{,
title = {schtools: Schloss Lab Tools for Reproducible Microbiome Research},
author = {Kelly Sovacool and Nick Lesniak and Patrick Schloss},
year = {2022},
note = {http://www.schlosslab.org/schtools/,
https://github.com/SchlossLab/schtools},
}
```
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ reference:
- is_nondesc
- load_deps
- log_snakemake
- starts_with('theme_')
4 changes: 2 additions & 2 deletions docs/dev/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/dev/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pkgdown_sha: ~
articles:
logo: logo.html
introduction: introduction.html
last_built: 2022-09-26T21:08Z
last_built: 2022-09-29T19:48Z
urls:
reference: http://www.schlosslab.org/schtools/reference
article: http://www.schlosslab.org/schtools/articles
Expand Down
Binary file modified docs/dev/reference/Rplot001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion docs/dev/reference/calc_relabun.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions docs/dev/reference/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added docs/dev/reference/theme_sovacool-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 105 additions & 0 deletions docs/dev/reference/theme_sovacool.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/dev/search.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions docs/dev/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,7 @@
<url>
<loc>http://www.schlosslab.org/schtools/dev/reference/set_knitr_opts.html</loc>
</url>
<url>
<loc>http://www.schlosslab.org/schtools/dev/reference/theme_sovacool.html</loc>
</url>
</urlset>
3 changes: 2 additions & 1 deletion man/calc_relabun.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading