Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
272 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
^README\.Rmd$ | ||
^\.travis\.yml$ | ||
^LICENSE\.md$ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
.Ruserdata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r | ||
|
||
language: R | ||
sudo: false | ||
cache: packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
exportPattern("^[[:alpha:]]+") | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
S3method(ggplot_add,new_aes) | ||
export(new_scale) | ||
export(new_scale_color) | ||
export(new_scale_colour) | ||
export(new_scale_fill) | ||
importFrom(ggplot2,ggplot_add) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
output: github_document | ||
--- | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
```{r setup, include = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>", | ||
fig.path = "man/figures/README-", | ||
out.width = "100%" | ||
) | ||
``` | ||
# ggnewscale | ||
|
||
[![Travis build status](https://travis-ci.org/eliocamp/ggnewscale.svg?branch=master)](https://travis-ci.org/eliocamp/ggnewscale) | ||
|
||
`ggnewscale` tries to make it painless to use multiple color and fill scales in `ggplot2`. It's very experimental, so use at your own risk! | ||
|
||
For another way of defining multiple scales, you can also try [relayer](https://github.com/clauswilke/relayer). | ||
|
||
## Installation | ||
|
||
Or you can install the development version from | ||
[GitHub](https://github.com/) with: | ||
|
||
``` r | ||
# install.packages("devtools") | ||
devtools::install_github("eliocamp/ggnewscale") | ||
``` | ||
|
||
## Usage | ||
|
||
The main function is `new_scale()` and its aliases `new_scale_color()` and `new_scale_fill()`. When added to a plot, every geom added after them will use a different scale. | ||
|
||
As an example, lets overlay some measurements over a contour map of topography using the beloed `volcano`. | ||
|
||
```{r} | ||
library(ggplot2) | ||
library(ggnewscale) | ||
# Equivalent to melt(volcano) | ||
topography <- expand.grid(x = 1:nrow(volcano), | ||
y = 1:ncol(volcano)) | ||
topography$z <- c(volcano) | ||
# point measurements of something at a few locations | ||
set.seed(42) | ||
measurements <- data.frame(x = runif(30, 1, 80), | ||
y = runif(30, 1, 60), | ||
thing = rnorm(30)) | ||
ggplot(mapping = aes(x, y)) + | ||
geom_contour(data = topography, aes(z = z, color = stat(level))) + | ||
# Color scale for topography | ||
scale_color_viridis_c(option = "D") + | ||
# geoms below will use another color scale | ||
new_scale_color() + | ||
geom_point(data = measurements, size = 3, aes(color = thing)) + | ||
# Color scale applied to geoms added after new_scale_color() | ||
scale_color_viridis_c(option = "A") | ||
``` | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
# ggnewscale | ||
|
||
[![Travis build | ||
status](https://travis-ci.org/eliocamp/ggnewscale.svg?branch=master)](https://travis-ci.org/eliocamp/ggnewscale) | ||
|
||
`ggnewscale` tries to make it painless to use multiple color and fill | ||
scales in `ggplot2`. It’s very experimental, so use at your own risk\! | ||
|
||
For another way of defining multiple scales, you can also try | ||
[relayer](https://github.com/clauswilke/relayer). | ||
|
||
## Installation | ||
|
||
Or you can install the development version from | ||
[GitHub](https://github.com/) with: | ||
|
||
``` r | ||
# install.packages("devtools") | ||
devtools::install_github("eliocamp/ggnewscale") | ||
``` | ||
|
||
## Usage | ||
|
||
The main function is `new_scale()` and its aliases `new_scale_color()` | ||
and `new_scale_fill()`. When added to a plot, every geom added after | ||
them will use a different scale. | ||
|
||
As an example, lets overlay some measurements over a contour map of | ||
topography using the beloed `volcano`. | ||
|
||
``` r | ||
library(ggplot2) | ||
library(ggnewscale) | ||
# Equivalent to melt(volcano) | ||
topography <- expand.grid(x = 1:nrow(volcano), | ||
y = 1:ncol(volcano)) | ||
topography$z <- c(volcano) | ||
|
||
# point measurements of something at a few locations | ||
set.seed(42) | ||
measurements <- data.frame(x = runif(30, 1, 80), | ||
y = runif(30, 1, 60), | ||
thing = rnorm(30)) | ||
|
||
ggplot(mapping = aes(x, y)) + | ||
geom_contour(data = topography, aes(z = z, color = stat(level))) + | ||
# Color scale for topography | ||
scale_color_viridis_c(option = "D") + | ||
# geoms below will use another color scale | ||
new_scale_color() + | ||
geom_point(data = measurements, size = 3, aes(color = thing)) + | ||
# Color scale applied to geoms added after new_scale_color() | ||
scale_color_viridis_c(option = "A") | ||
``` | ||
|
||
<img src="man/figures/README-unnamed-chunk-1-1.png" width="100%" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.