Skip to content

Commit

Permalink
add tests (reverse, pal n, theme ticks), add news 1.1.0, update readm…
Browse files Browse the repository at this point in the history
…e, graity falls font
  • Loading branch information
Ryo-N7 committed Oct 20, 2019
1 parent d1bb880 commit 1d68713
Show file tree
Hide file tree
Showing 17 changed files with 438 additions and 23 deletions.
19 changes: 19 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# tvthemes 1.1.0

* New palette:
* Gravity Falls
* New font:
* "Gravitation Falls"
* Renamed functions to fit `*_camelCase()` style:
* `import_titilliumWeb()`, `import_robotoCondensed()`, `import_chelseaMarket()`
* Renamed 'Avatar: The Last Airbender' functions:
* `scale_*_avatar()`, `theme_avatar()`
* Deprecated functions:
* `import_titillium_web()`, `import_roboto_condensed()`, `scale_*_avatarTLA()`,
`theme_theLastAirbender()`
* Deleted functions:
* `import_ChelseaMarket()` (replaced by `import_chelseaMarket()`)
* Added `{packagedown}` website
* Split README into vignettes
* Added more tests

# tvthemes 1.0.0

* Released on CRAN! (September 3rd, 2019)
Expand Down
18 changes: 8 additions & 10 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ knitr::opts_chunk$set(
)
```

# tvthemes 1.0.0 <img src="man/figures/logo.png" align="right" style="padding-left:10px;background-color:white;" />
# tvthemes 1.1.0 <img src="man/figures/logo.png" align="right" style="padding-left:10px;background-color:white;" />

<!-- badges: start -->
[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)
Expand All @@ -28,20 +28,17 @@ knitr::opts_chunk$set(

[Ryo Nakagawara | Twitter: `@R_by_Ryo`](https://twitter.com/R_by_Ryo/)

**`tvthemes 1.0.0` is now on CRAN so please check out the [announcement blog post](https://ryo-n7.github.io/2019-09-06-tvthemes-CRAN-announcement/)!**
The `tvthemes` package is a collection of various `ggplot2` themes and color/fill palettes based on everybody's favorite TV shows. What kick-started this whole package was my [blogpost](https://ryo-n7.github.io/2019-02-15-visualize-brooklyn-nine-nine/) looking at simple TV stats on my current favorite TV show, Brooklyn Nine-Nine. I got a lot of good feedback on the colors I used for the custom `ggplot2` theme and color palettes so I decided to expand it to other shows that I love! Suggestions and Pull Requests for palettes/themes are welcome!

The `tvthemes` package is a collection of various `ggplot2` themes and color/fill palettes based on everybody's favorite TV shows. What kick-started this whole package was my [blogpost](https://ryo-n7.github.io/2019-02-15-visualize-brooklyn-nine-nine/) looking at simple TV stats on my current favorite TV show, Brooklyn Nine-Nine. I got a lot of good feedback on the colors I used for the custom `ggplot2` theme and color palettes so I decided to expand it to other shows that I love! You can also learn about `tvthemes` from the introductory blog post on my website, [here](https://ryo-n7.github.io/2019-05-16-introducing-tvthemes-package/).
Suggestions and Pull Requests for palettes/themes are welcome!
* [Intro to `tvthemes` blog post](https://ryo-n7.github.io/2019-05-16-introducing-tvthemes-package/)
* [`tvthemes 1.0.0` & CRAN release blog post](https://ryo-n7.github.io/2019-09-06-tvthemes-CRAN-announcement/)

```{r, echo=FALSE, message=FALSE}
```{r b99header, eval=FALSE}
library(tvthemes)
library(ggplot2)
library(glue)
library(extrafont)
loadfonts()
```
loadfonts(quiet = TRUE)
```{r b99header, eval=FALSE}
ggplot(mpg, aes(displ)) +
geom_histogram(aes(fill = class),
col = "black", size = 0.1,
Expand All @@ -56,7 +53,7 @@ ggplot(mpg, aes(displ)) +
subtitle.size = 14)
```

![b99header](https://i.imgur.com/SjxWFXd.png)
![b99d](https://i.imgur.com/SjxWFXd.png)

## Current list of TV shows

Expand All @@ -81,6 +78,7 @@ You can install `tvthemes` by:

```{r, eval=FALSE}
## install.packages(devtools)
## for development version:
devtools::install_github("Ryo-N7/tvthemes")
## v1.0.0 is available on CRAN!
Expand Down
30 changes: 18 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# tvthemes 1.0.0 <img src="man/figures/logo.png" align="right" style="padding-left:10px;background-color:white;" />
# tvthemes 1.1.0 <img src="man/figures/logo.png" align="right" style="padding-left:10px;background-color:white;" />

<!-- badges: start -->

Expand All @@ -17,23 +17,29 @@ status](https://codecov.io/gh/Ryo-N7/tvthemes/branch/master/graph/badge.svg)](ht

[Ryo Nakagawara | Twitter: `@R_by_Ryo`](https://twitter.com/R_by_Ryo/)

**`tvthemes 1.0.0` is now on CRAN so please check out the [announcement
blog
post](https://ryo-n7.github.io/2019-09-06-tvthemes-CRAN-announcement/)\!**

The `tvthemes` package is a collection of various `ggplot2` themes and
color/fill palettes based on everybody’s favorite TV shows. What
kick-started this whole package was my
[blogpost](https://ryo-n7.github.io/2019-02-15-visualize-brooklyn-nine-nine/)
looking at simple TV stats on my current favorite TV show, Brooklyn
Nine-Nine. I got a lot of good feedback on the colors I used for the
custom `ggplot2` theme and color palettes so I decided to expand it to
other shows that I love\! You can also learn about `tvthemes` from the
introductory blog post on my website,
[here](https://ryo-n7.github.io/2019-05-16-introducing-tvthemes-package/).
Suggestions and Pull Requests for palettes/themes are welcome\!
other shows that I love\! Suggestions and Pull Requests for
palettes/themes are welcome\!

- [Intro to `tvthemes` blog
post](https://ryo-n7.github.io/2019-05-16-introducing-tvthemes-package/)
- [`tvthemes 1.0.0` & CRAN release blog
post](https://ryo-n7.github.io/2019-09-06-tvthemes-CRAN-announcement/)

<!-- end list -->

``` r
library(tvthemes)
library(ggplot2)
library(extrafont)
loadfonts(quiet = TRUE)

ggplot(mpg, aes(displ)) +
geom_histogram(aes(fill = class),
col = "black", size = 0.1,
Expand All @@ -48,7 +54,7 @@ ggplot(mpg, aes(displ)) +
subtitle.size = 14)
```

![b99header](https://i.imgur.com/SjxWFXd.png)
![b99d](https://i.imgur.com/SjxWFXd.png)

## Current list of TV shows

Expand Down Expand Up @@ -76,6 +82,7 @@ You can install `tvthemes` by:

``` r
## install.packages(devtools)
## for development version:
devtools::install_github("Ryo-N7/tvthemes")

## v1.0.0 is available on CRAN!
Expand All @@ -94,8 +101,7 @@ See vignette.

# Examples

You can find the code for all the examples in the “Examples”
Vignette.
You can find the code for all the examples in the “Examples” Vignette.

## Brooklyn Nine-Nine

Expand Down
Binary file added man/figures/README-b99header-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions tests/testthat/test-attackontitan.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ context("test-attackontitan")
## Attack on Titan
test_that("attackOnTitan_pal raises warning with large number, x > 8", {
expect_warning(attackOnTitan_pal()(9))
expect_warning(attackOnTitan_pal(reverse = TRUE)(9))
expect_error(attackOnTitan_pal(n = 9))
})

test_that("scale_colour_attackOnTitan equals scale_color_attackOnTitan", {
Expand Down
4 changes: 3 additions & 1 deletion tests/testthat/test-bighero6.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
context("test-bighero6")

## Big Hero 6
test_that("bigHero6_pal raises warning with large number, x > 12", {
test_that("bigHero6_pal raises warning with large number, x > 8", {
expect_warning(bigHero6_pal()(9))
expect_warning(bigHero6_pal(reverse = TRUE)(9))
expect_error(bigHero6_pal(n = 9))
})

test_that("scale_colour_bigHero6 equals scale_color_bigHero6", {
Expand Down
30 changes: 30 additions & 0 deletions tests/testthat/test-brooklyn99.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,40 @@ test_that("theme_brooklyn99 works", {
expect_equal(thm$legend.text$colour, "#F9FEFF")
expect_equal(thm$legend.title$colour, "#F9FEFF")
expect_equal(thm$legend.position, "bottom")

## ticks == TRUE
thm <- theme_brooklyn99(ticks = TRUE)
expect_s3_class(thm, "theme")
## font
expect_equal(thm$text$family, "")
expect_null(thm$plot.title$family)
expect_null(thm$legend.title$family)
expect_null(thm$legend.text$family)
## size
expect_equal(thm$text$size, 14)
expect_equal(thm$plot.title$size, 18)
expect_equal(thm$plot.subtitle$size, 12)
expect_equal(thm$axis.text$size, 12)
expect_equal(thm$axis.title$size, 14)
expect_equal(thm$legend.text$size, 9)
expect_equal(thm$legend.title$size, 10)
## ticks
expect_equal(thm$axis.ticks$size, 0.15)
## color
expect_equal(thm$text$colour, "#F9FEFF")
expect_equal(thm$plot.title$colour, "#F9FEFF")
expect_equal(thm$plot.subtitle$colour, "#F9FEFF")
expect_equal(thm$axis.text$colour, "#F9FEFF")
expect_equal(thm$axis.title$colour, "#F9FEFF")
expect_equal(thm$legend.text$colour, "#F9FEFF")
expect_equal(thm$legend.title$colour, "#F9FEFF")
expect_equal(thm$legend.position, "bottom")
})

test_that("brooklyn99_pal raises warning with large number, x > 10", {
expect_warning(brooklyn99_pal()(11))
expect_warning(brooklyn99_pal(reverse = TRUE)(11))
expect_error(brooklyn99_pal(n = 12))
})

test_that("scale_colour_brooklyn99/dark equals scale_color_brooklyn99/dark", {
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-gameofthrones.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ context("test-gameofthrones")
## House Stark ----
test_that("stark_pal raises warning with large number, x > 9", {
expect_warning(westeros_pal(palette = "Stark")(10))
expect_warning(westeros_pal(reverse = TRUE)(10))
expect_error(westeros_pal(n = 10))
})

test_that("scale_colour_stark equals scale_color_stark", {
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-gravityfalls.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ context("test-gravityFalls")
## Big Hero 6
test_that("gravityFalls_pal raises warning with large number, x > 15", {
expect_warning(gravityFalls_pal()(15))
expect_warning(gravityFalls_pal(reverse = TRUE)(15))
expect_error(gravityFalls_pal(n = 15))
})

test_that("scale_colour_gravityFalls equals scale_color_gravityFalls", {
Expand Down
86 changes: 86 additions & 0 deletions tests/testthat/test-hilda.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,41 @@ test_that("theme_hildaDay works", {
expect_equal(thm$legend.text$colour, "#93a1a1")
expect_equal(thm$legend.title$colour, "#659794")
expect_equal(thm$legend.position, "bottom")

## ticks == TRUE
thm <- theme_hildaDay(ticks = TRUE)
expect_s3_class(thm, "theme")
## font
expect_equal(thm$text$family, "Chelsea Market")
expect_equal(thm$plot.title$family, "Chelsea Market")
expect_equal(thm$legend.title$family, "Chelsea Market")
expect_equal(thm$legend.text$family, "Chelsea Market")
## size
expect_equal(thm$text$size, 14)
expect_equal(thm$plot.title$size, 18)
expect_equal(thm$plot.subtitle$size, 12)
expect_equal(thm$axis.text$size, 12)
expect_equal(thm$axis.title$size, 14)
expect_equal(thm$legend.text$size, 9)
expect_equal(thm$legend.title$size, 10)
## ticks
expect_equal(thm$axis.ticks$size, 0.15)
## color
expect_equal(thm$text$colour, "#659794")
expect_equal(thm$plot.title$colour, "#659794")
expect_equal(thm$plot.subtitle$colour, "#659794")
expect_equal(thm$axis.text$colour, "#93a1a1")
expect_equal(thm$axis.title$colour, "#659794")
expect_equal(thm$legend.text$colour, "#93a1a1")
expect_equal(thm$legend.title$colour, "#659794")
expect_equal(thm$legend.position, "bottom")
})

## Hilda Day
test_that("hilda_pal raises warning with large number, x > 8", {
expect_warning(hilda_pal("Day")(9))
expect_warning(hilda_pal(reverse = TRUE)(9))
expect_error(hilda_pal(n = 9))
})

test_that("scale_colour_hilda equals scale_color_hilda", {
Expand Down Expand Up @@ -71,6 +101,34 @@ test_that("theme_hildaDusk works", {
expect_equal(thm$legend.text$colour, "#F9FEFF")
expect_equal(thm$legend.title$colour, "#F9FEFF")
expect_equal(thm$legend.position, "bottom")

## ticks == TRUE
thm <- theme_hildaDusk(ticks = TRUE)
expect_s3_class(thm, "theme")
## font
expect_equal(thm$text$family, "Chelsea Market")
expect_equal(thm$plot.title$family, "Chelsea Market")
expect_equal(thm$legend.title$family, "Chelsea Market")
expect_equal(thm$legend.text$family, "Chelsea Market")
## size
expect_equal(thm$text$size, 14)
expect_equal(thm$plot.title$size, 18)
expect_equal(thm$plot.subtitle$size, 12)
expect_equal(thm$axis.text$size, 12)
expect_equal(thm$axis.title$size, 14)
expect_equal(thm$legend.text$size, 9)
expect_equal(thm$legend.title$size, 10)
## ticks
expect_equal(thm$axis.ticks$size, 0.15)
## color
expect_equal(thm$text$colour, "#F9FEFF")
expect_equal(thm$plot.title$colour, "#F9FEFF")
expect_equal(thm$plot.subtitle$colour, "#F9FEFF")
expect_equal(thm$axis.text$colour, "#F9FEFF")
expect_equal(thm$axis.title$colour, "#F9FEFF")
expect_equal(thm$legend.text$colour, "#F9FEFF")
expect_equal(thm$legend.title$colour, "#F9FEFF")
expect_equal(thm$legend.position, "bottom")
})

## Hilda Dusk
Expand Down Expand Up @@ -116,6 +174,34 @@ test_that("theme_hildaNight works", {
expect_equal(thm$legend.text$colour, "#F9FEFF")
expect_equal(thm$legend.title$colour, "#F9FEFF")
expect_equal(thm$legend.position, "bottom")

## ticks == TRUE
thm <- theme_hildaNight(ticks = TRUE)
expect_s3_class(thm, "theme")
## font
expect_equal(thm$text$family, "Chelsea Market")
expect_equal(thm$plot.title$family, "Chelsea Market")
expect_equal(thm$legend.title$family, "Chelsea Market")
expect_equal(thm$legend.text$family, "Chelsea Market")
## size
expect_equal(thm$text$size, 14)
expect_equal(thm$plot.title$size, 18)
expect_equal(thm$plot.subtitle$size, 12)
expect_equal(thm$axis.text$size, 12)
expect_equal(thm$axis.title$size, 14)
expect_equal(thm$legend.text$size, 9)
expect_equal(thm$legend.title$size, 10)
## ticks
expect_equal(thm$axis.ticks$size, 0.15)
## color
expect_equal(thm$text$colour, "#F9FEFF")
expect_equal(thm$plot.title$colour, "#F9FEFF")
expect_equal(thm$plot.subtitle$colour, "#F9FEFF")
expect_equal(thm$axis.text$colour, "#F9FEFF")
expect_equal(thm$axis.title$colour, "#F9FEFF")
expect_equal(thm$legend.text$colour, "#F9FEFF")
expect_equal(thm$legend.title$colour, "#F9FEFF")
expect_equal(thm$legend.position, "bottom")
})

## Hilda Night
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-kimpossible.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ context("test-kimpossible")
## Kim Possible
test_that("kimPossible_pal raises warning with large number, x > 12", {
expect_warning(kimPossible_pal()(13))
expect_warning(kimPossible_pal(reverse = TRUE)(13))
expect_error(kimPossible_pal(n = 13))
})

test_that("scale_colour_kimPossible equals scale_color_kimPossible", {
Expand Down
Loading

0 comments on commit 1d68713

Please sign in to comment.