diff --git a/Makefile b/Makefile index 982118c..43a7d77 100644 --- a/Makefile +++ b/Makefile @@ -28,3 +28,7 @@ style: .PHONY: lint lint: $(RSCRIPT) -e 'devtools::lint()' + +README.md: README.Rmd + $(RSCRIPT) -e 'knitr::knit("$<", output = "$@", quiet = TRUE)' + diff --git a/README.Rmd b/README.Rmd new file mode 100644 index 0000000..6cc2f9d --- /dev/null +++ b/README.Rmd @@ -0,0 +1,138 @@ +--- +output: github_document +--- + + + +```{r, echo = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.path = "man/figures/README-" +) +``` + +[![R-CMD-check](https://github.com/jrnold/ggthemes/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jrnold/ggthemes/actions/workflows/R-CMD-check.yaml) +[![Code Coverage Status](https://codecov.io/gh/jrnold/ggthemes/branch/master/graph/badge.svg)](https://codecov.io/github/jrnold/ggthemes?branch=master) +[![rstudio mirror downloads](http://cranlogs.r-pkg.org/badges/ggthemes)](https://github.com/metacran/cranlogs.app) +[![CRAN status](https://www.r-pkg.org/badges/version/ggthemes)](https://CRAN.R-project.org/package=ggthemes) +[![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable) + +Some extra geoms, scales, and themes for +[ggplot](https://ggplot2.tidyverse.org/). + +## Install + +To install the stable version from CRAN, + +```r +install.packages('ggthemes', dependencies = TRUE) +``` + +Or, to install the development version from github, use the +**devtools** package, + +```r +library("devtools") +install_github(c("hadley/ggplot2", "jrnold/ggthemes")) +``` + +## How to use + +For a quick tutorial, check out [Rafael Irizarry's book](https://rafalab.github.io/dsbook/ggplot2.html#add-on-packages). + +## Examples + +```{r} +library("ggplot2") +library("ggthemes") + +mtcars2 <- within(mtcars, { + vs <- factor(vs, labels = c("V-shaped", "Straight")) + am <- factor(am, labels = c("Automatic", "Manual")) + cyl <- factor(cyl) + gear <- factor(gear) +}) + +p1 <- ggplot(mtcars2) + + geom_point(aes(x = wt, y = mpg, colour = gear)) + + labs( + title = "Fuel economy declines as weight increases", + subtitle = "(1973-74)", + caption = "Data from the 1974 Motor Trend US magazine.", + x = "Weight (1000 lbs)", + y = "Fuel economy (mpg)", + colour = "Gears" + ) +``` + +```{r,theme_calc} +p1 + + scale_color_calc() + + theme_calc() +``` + +```{r,theme_clean} +p1 + theme_clean() +``` + +```{r,theme_economist} +p1 + theme_economist() + + scale_colour_economist() +``` + +```{r,theme_excel} +p1 + theme_excel() + + scale_colour_excel() +``` + +```{r,theme_excel_new} +p1 + theme_excel_new() + + scale_colour_excel_new() +``` + +```{r,theme_igray} +p1 + theme_igray() +``` + +```{r,theme_par} +p1 + theme_par() +``` + +```{r,theme_fivethirtyeight} +p1 + theme_fivethirtyeight() +``` + +```{r,theme_few} +p1 + theme_few() + + scale_colour_few() +``` +```{r,theme_solarized} +p1 + theme_solarized() + + scale_colour_solarized() +``` + +```{r,theme_solarized_dark} +p1 + theme_solarized(light=FALSE) + + scale_colour_solarized() +``` + +```{r,theme_solid} +p1 + theme_solid() +``` + +```{r,theme_stata} +p1 + theme_tufte() +``` + +```{r,theme_wsj} +p1 + theme_wsj(base_size = 8) + scale_color_wsj() +``` + +```{r,scale_colorblind} +p1 + scale_color_colorblind() +``` + +```{r,scale_color_tableau} +p1 + scale_color_tableau() +``` diff --git a/README.md b/README.md index a7092a1..00963a3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,13 @@ + + + [![R-CMD-check](https://github.com/jrnold/ggthemes/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jrnold/ggthemes/actions/workflows/R-CMD-check.yaml) -[![Code Coverage Status](https://codecov.io/gh/jrnold/ggthemes/branch/master/graph/badge.svg)](https://codecov.io/github/jrnold/ggthemes?branch=master) -[![rstudio mirror downloads](http://cranlogs.r-pkg.org/badges/ggthemes)](https://github.com/metacran/cranlogs.app) -[![CRAN status](https://www.r-pkg.org/badges/version/ggthemes)](https://CRAN.R-project.org/package=ggthemes) +[![Code Coverage +Status](https://codecov.io/gh/jrnold/ggthemes/branch/master/graph/badge.svg)](https://codecov.io/github/jrnold/ggthemes?branch=master) +[![rstudio mirror +downloads](http://cranlogs.r-pkg.org/badges/ggthemes)](https://github.com/metacran/cranlogs.app) +[![CRAN +status](https://www.r-pkg.org/badges/version/ggthemes)](https://CRAN.R-project.org/package=ggthemes) [![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable) Some extra geoms, scales, and themes for @@ -11,18 +17,148 @@ Some extra geoms, scales, and themes for To install the stable version from CRAN, -```r +``` r install.packages('ggthemes', dependencies = TRUE) ``` -Or, to install the development version from github, use the -**devtools** package, +Or, to install the development version from github, use the **devtools** +package, -```r +``` r library("devtools") install_github(c("hadley/ggplot2", "jrnold/ggthemes")) ``` ## How to use -For a quick tutorial, check out [Rafael Irizarry's book](https://rafalab.github.io/dsbook/ggplot2.html#add-on-packages). For more examples [click here](https://github.com/BTJ01/ggthemes/tree/master/inst/examples). +For a quick tutorial, check out [Rafael Irizarry’s +book](https://rafalab.github.io/dsbook/ggplot2.html#add-on-packages). + +## Examples + +``` r +library("ggplot2") +library("ggthemes") + +mtcars2 <- within(mtcars, { + vs <- factor(vs, labels = c("V-shaped", "Straight")) + am <- factor(am, labels = c("Automatic", "Manual")) + cyl <- factor(cyl) + gear <- factor(gear) +}) + +p1 <- ggplot(mtcars2) + + geom_point(aes(x = wt, y = mpg, colour = gear)) + + labs( + title = "Fuel economy declines as weight increases", + subtitle = "(1973-74)", + caption = "Data from the 1974 Motor Trend US magazine.", + x = "Weight (1000 lbs)", + y = "Fuel economy (mpg)", + colour = "Gears" + ) +``` + +``` r +p1 + + scale_color_calc() + + theme_calc() +``` + +![](man/figures/README-theme_calc-1.png) + +``` r +p1 + theme_clean() +``` + +![](man/figures/README-theme_clean-1.png) + +``` r +p1 + theme_economist() + + scale_colour_economist() +``` + +![](man/figures/README-theme_economist-1.png) + +``` r +p1 + theme_excel() + + scale_colour_excel() +``` + +![](man/figures/README-theme_excel-1.png) + +``` r +p1 + theme_excel_new() + + scale_colour_excel_new() +``` + +![](man/figures/README-theme_excel_new-1.png) + +``` r +p1 + theme_igray() +``` + +![](man/figures/README-theme_igray-1.png) + +``` r +p1 + theme_par() +``` + +![](man/figures/README-theme_par-1.png) + +``` r +p1 + theme_fivethirtyeight() +``` + +![](man/figures/README-theme_fivethirtyeight-1.png) + +``` r +p1 + theme_few() + + scale_colour_few() +``` + +![](man/figures/README-theme_few-1.png) + +``` r +p1 + theme_solarized() + + scale_colour_solarized() +``` + +![](man/figures/README-theme_solarized-1.png) + +``` r +p1 + theme_solarized(light=FALSE) + + scale_colour_solarized() +``` + +![](man/figures/README-theme_solarized_dark-1.png) + +``` r +p1 + theme_solid() +``` + +![](man/figures/README-theme_solid-1.png) + +``` r +p1 + theme_tufte() +``` + +![](man/figures/README-theme_stata-1.png) + +``` r +p1 + theme_wsj(base_size = 8) + scale_color_wsj() +``` + +![](man/figures/README-theme_wsj-1.png) + +``` r +p1 + scale_color_colorblind() +``` + +![](man/figures/README-scale_colorblind-1.png) + +``` r +p1 + scale_color_tableau() +``` + +![](man/figures/README-scale_color_tableau-1.png) diff --git a/man/figures/README-scale_color_tableau-1.png b/man/figures/README-scale_color_tableau-1.png new file mode 100644 index 0000000..1a27468 Binary files /dev/null and b/man/figures/README-scale_color_tableau-1.png differ diff --git a/man/figures/README-scale_colorblind-1.png b/man/figures/README-scale_colorblind-1.png new file mode 100644 index 0000000..cc40fe2 Binary files /dev/null and b/man/figures/README-scale_colorblind-1.png differ diff --git a/man/figures/README-theme_calc-1.png b/man/figures/README-theme_calc-1.png new file mode 100644 index 0000000..b09e331 Binary files /dev/null and b/man/figures/README-theme_calc-1.png differ diff --git a/man/figures/README-theme_clean-1.png b/man/figures/README-theme_clean-1.png new file mode 100644 index 0000000..0fb17bb Binary files /dev/null and b/man/figures/README-theme_clean-1.png differ diff --git a/man/figures/README-theme_economist-1.png b/man/figures/README-theme_economist-1.png new file mode 100644 index 0000000..54130a3 Binary files /dev/null and b/man/figures/README-theme_economist-1.png differ diff --git a/man/figures/README-theme_excel-1.png b/man/figures/README-theme_excel-1.png new file mode 100644 index 0000000..4397c86 Binary files /dev/null and b/man/figures/README-theme_excel-1.png differ diff --git a/man/figures/README-theme_excel_new-1.png b/man/figures/README-theme_excel_new-1.png new file mode 100644 index 0000000..361a85e Binary files /dev/null and b/man/figures/README-theme_excel_new-1.png differ diff --git a/man/figures/README-theme_few-1.png b/man/figures/README-theme_few-1.png new file mode 100644 index 0000000..5c8a60b Binary files /dev/null and b/man/figures/README-theme_few-1.png differ diff --git a/man/figures/README-theme_fivethirtyeight-1.png b/man/figures/README-theme_fivethirtyeight-1.png new file mode 100644 index 0000000..e851afe Binary files /dev/null and b/man/figures/README-theme_fivethirtyeight-1.png differ diff --git a/man/figures/README-theme_igray-1.png b/man/figures/README-theme_igray-1.png new file mode 100644 index 0000000..bd0b9ad Binary files /dev/null and b/man/figures/README-theme_igray-1.png differ diff --git a/man/figures/README-theme_par-1.png b/man/figures/README-theme_par-1.png new file mode 100644 index 0000000..132b520 Binary files /dev/null and b/man/figures/README-theme_par-1.png differ diff --git a/man/figures/README-theme_solarized-1.png b/man/figures/README-theme_solarized-1.png new file mode 100644 index 0000000..6b4129d Binary files /dev/null and b/man/figures/README-theme_solarized-1.png differ diff --git a/man/figures/README-theme_solarized_dark-1.png b/man/figures/README-theme_solarized_dark-1.png new file mode 100644 index 0000000..3db6759 Binary files /dev/null and b/man/figures/README-theme_solarized_dark-1.png differ diff --git a/man/figures/README-theme_solid-1.png b/man/figures/README-theme_solid-1.png new file mode 100644 index 0000000..28d6383 Binary files /dev/null and b/man/figures/README-theme_solid-1.png differ diff --git a/man/figures/README-theme_stata-1.png b/man/figures/README-theme_stata-1.png new file mode 100644 index 0000000..01f202b Binary files /dev/null and b/man/figures/README-theme_stata-1.png differ diff --git a/man/figures/README-theme_wsj-1.png b/man/figures/README-theme_wsj-1.png new file mode 100644 index 0000000..82ed9be Binary files /dev/null and b/man/figures/README-theme_wsj-1.png differ