Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
sainathadapa committed Mar 3, 2017
1 parent b5fbb25 commit ffe5db7
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 48 deletions.
45 changes: 31 additions & 14 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ output:
md_document:
variant: markdown_github
toc: true
toc_depth: 2
---

<!-- README.md is generated from README.Rmd. Please edit that file -->
Expand All @@ -11,7 +12,13 @@ output:
suppressPackageStartupMessages(library(ggplot2))
suppressPackageStartupMessages(library(gridExtra))
library(ggthemr)
example_plot <- ggplot(diamonds, aes(price, fill = factor(cut))) + geom_histogram(binwidth = 850) + xlab('Price (USD)') + ylab('Count') + scale_x_continuous(label = function(x) paste0(x / 1000, 'k')) + list(theme(legend.position = 'none'), scale_y_continuous(label = function(x) format(x, big.mark = ",", scientific = FALSE)))
example_plot <- ggplot(diamonds, aes(price, fill = factor(cut))) +
geom_histogram(binwidth = 850) +
xlab('Price (USD)') +
ylab('Count') +
scale_x_continuous(label = function(x) paste0(x / 1000, 'k')) +
theme(legend.position = 'none') +
scale_y_continuous(label = function(x) format(x, big.mark = ",", scientific = FALSE))
source('scripts/preview_theme.R')
source('scripts/preview_layout.R')
```
Expand All @@ -32,7 +39,7 @@ There are a number of preset palettes and layouts, and methods to create your ow
Installation
-------------------------

This package is still under development and isn't too stable yet, but can be installed using [devtools](http://cran.r-project.org/web/packages/devtools/index.html).
This package is still under development, but can be installed using [devtools](http://cran.r-project.org/web/packages/devtools/index.html).

```{r eval=FALSE}
devtools::install_github('cttobin/ggthemr')
Expand All @@ -53,18 +60,6 @@ That's it. Any ggplot you create from then on will have the theme applied. You c
ggthemr_reset()
```


Further Development
-------------------------

Features on the way:

* More palettes and layouts.
* Options to control fonts.
* Ability to reset themes back to default.
* Theme modifiers (so you can do things like `plot + no_legend()`, `plot + no_axes()` etc.).


Palettes
-------------------------

Expand Down Expand Up @@ -350,4 +345,26 @@ mpg_plot + scale_fill_manual(values = rev(to_swap))

**Note:** the first colour in a swatch is a special one. It is reserved for outlining boxplots, text etc. So that's why the second and third colours were swapped.

A note about theme setting
--------------------------
ggthemr does three different things while setting a theme.

1. It updates the default ggplot2 theme with the specified ggthemr theme by using the `ggplot2::theme_set()` function.
2. It modifies the aesthetic defaults for all geoms using the `ggplot2::update_geom_defaults()` function.
3. It creates functions for all the different scales in the global environment.

In case, if you do not want to set the theme this way, use the `set_theme = FALSE` option while using the `ggthemr` function. An example of setting theme, geom aesthetic defaults and scales manually:
```{r}
ggthemr_reset()
dust_theme <- ggthemr('dust', set_theme = FALSE)
example_plot
example_plot + dust_theme$theme
example_plot + dust_theme$theme + dust_theme$scales$scale_fill_discrete()
do.call(what = ggplot2::update_geom_defaults, args = dust_theme$geom_defaults$bar)
ggplot(diamonds, aes(price)) + geom_histogram(binwidth = 850) + dust_theme$theme
```


License
-------
Released under GPL-3.
80 changes: 46 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,15 @@
- [ggthemr](#ggthemr)
- [Installation](#installation)
- [Usage](#usage)
- [Further Development](#further-development)
- [Palettes](#palettes)
- [flat](#flat)
- [flat dark](#flat-dark)
- [camoflauge](#camoflauge)
- [chalk](#chalk)
- [copper](#copper)
- [dust](#dust)
- [earth](#earth)
- [fresh](#fresh)
- [grape](#grape)
- [grass](#grass)
- [greyscale](#greyscale)
- [light](#light)
- [lilac](#lilac)
- [pale](#pale)
- [sea](#sea)
- [sky](#sky)
- [solarized](#solarized)
- [Custom Palettes](#custom-palettes)
- [Layouts](#layouts)
- [Clean](#clean)
- [Clear (default)](#clear-default)
- [Minimal](#minimal)
- [Plain](#plain)
- [Scientific](#scientific)
- [Spacing](#spacing)
- [Type](#type)
- [Tweaking Themes](#tweaking-themes)
- [Plot Adjustments](#plot-adjustments)
- [A note about theme setting](#a-note-about-theme-setting)
- [License](#license)

<!-- README.md is generated from README.Rmd. Please edit that file -->
ggthemr
Expand All @@ -48,7 +27,7 @@ There are a number of preset palettes and layouts, and methods to create your ow
Installation
------------

This package is still under development and isn't too stable yet, but can be installed using [devtools](http://cran.r-project.org/web/packages/devtools/index.html).
This package is still under development, but can be installed using [devtools](http://cran.r-project.org/web/packages/devtools/index.html).

``` r
devtools::install_github('cttobin/ggthemr')
Expand All @@ -69,16 +48,6 @@ That's it. Any ggplot you create from then on will have the theme applied. You c
ggthemr_reset()
```

Further Development
-------------------

Features on the way:

- More palettes and layouts.
- Options to control fonts.
- Ability to reset themes back to default.
- Theme modifiers (so you can do things like `plot + no_legend()`, `plot + no_axes()` etc.).

Palettes
--------

Expand Down Expand Up @@ -302,3 +271,46 @@ mpg_plot + scale_fill_manual(values = rev(to_swap))
![](README_files/figure-markdown_github/unnamed-chunk-37-1.png)

**Note:** the first colour in a swatch is a special one. It is reserved for outlining boxplots, text etc. So that's why the second and third colours were swapped.

A note about theme setting
--------------------------

ggthemr does three different things while setting a theme.

1. It updates the default ggplot2 theme with the specified ggthemr theme by using the `ggplot2::theme_set()` function.
2. It modifies the aesthetic defaults for all geoms using the `ggplot2::update_geom_defaults()` function.
3. It creates functions for all the different scales in the global environment.

In case, if you do not want to set the theme this way, use the `set_theme = FALSE` option while using the `ggthemr` function. An example of setting theme, geom aesthetic defaults and scales manually:

``` r
ggthemr_reset()
dust_theme <- ggthemr('dust', set_theme = FALSE)
example_plot
```

![](README_files/figure-markdown_github/unnamed-chunk-38-1.png)

``` r
example_plot + dust_theme$theme
```

![](README_files/figure-markdown_github/unnamed-chunk-38-2.png)

``` r
example_plot + dust_theme$theme + dust_theme$scales$scale_fill_discrete()
```

![](README_files/figure-markdown_github/unnamed-chunk-38-3.png)

``` r
do.call(what = ggplot2::update_geom_defaults, args = dust_theme$geom_defaults$bar)
ggplot(diamonds, aes(price)) + geom_histogram(binwidth = 850) + dust_theme$theme
```

![](README_files/figure-markdown_github/unnamed-chunk-38-4.png)

License
-------

Released under GPL-3.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ffe5db7

Please sign in to comment.