ggnewscale
Multiple Fill, Color and Other Scales in `ggplot2`
Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
✓Academic publication links
Links to: zenodo.org -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (18.9%) to scientific vocabulary
Keywords
ggplot2
r
r-package
rstats
Keywords from Contributors
visualisation
Last synced: 6 months ago
·
JSON representation
Repository
Multiple Fill, Color and Other Scales in `ggplot2`
Basic Info
- Host: GitHub
- Owner: eliocamp
- License: gpl-3.0
- Language: TeX
- Default Branch: master
- Homepage: https://eliocamp.github.io/ggnewscale/
- Size: 10.5 MB
Statistics
- Stars: 423
- Watchers: 10
- Forks: 18
- Open Issues: 5
- Releases: 15
Topics
ggplot2
r
r-package
rstats
Created about 7 years ago
· Last pushed 8 months ago
Metadata Files
Readme
Changelog
License
README.Rmd
---
output: github_document
knit: (function(input, ...) devtools::build_readme())
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```
# ggnewscale
[](https://github.com/eliocamp/ggnewscale/actions)
[](https://app.codecov.io/gh/eliocamp/ggnewscale?branch=master)
[](https://zenodo.org/badge/latestdoi/161934647)
[](https://cran.r-project.org/package=ggnewscale)
[](https://github.com/eliocamp/ggnewscale/actions/workflows/R-CMD-check.yaml)
`ggnewscale` tries to make it painless to use multiple scales in `ggplot2`. Although originally intended to use with colour and fill, it should work with any `aes`, such as `shape`, `linetype` and the rest.
[ggnewscale: spend 400% more time tweaking your ggplot!](https://web.archive.org/web/20220511154749/https://twitter.com/mattansb/status/1524415881920528385)
For another way of defining multiple scales, you can also try [relayer](https://github.com/clauswilke/relayer).
## How to install
You can install ggnewscale from CRAN with:
```{r CRAN-installation, eval = FALSE}
install.packages("ggnewscale")
```
Or the development version with:
```r
# install.packages("devtools")
devtools::install_github("eliocamp/ggnewscale")
```
## How to cite
If you use ggnewscale in a publication, I'll be grateful if you cited it. To get the suggested citation for this (and any other R package) you can use:
```{r}
citation("ggnewscale")
```
If you use knitr, [you can automate this](https://bookdown.org/yihui/rmarkdown-cookbook/write-bib.html) with
```r
knitr::write_bib(c("ggnewscale"), "packages.bib")
```
And then add citations with `@R-ggnewscale`.
Click to see a list of some publications that have cited ggnewscale. Thanks!
```{r echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
bib <- "ggnewscale-cited.bib"
RefManageR::ReadBib(bib)
```
## 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, let's overlay some measurements over a contour map of topography using the beloved `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")
```
If you want to create new scales for other `aes`, you can call `new_scale` with the name of the `aes`. For example, use
```{r, eval = FALSE}
new_scale("linetype")
```
to add multiple linetype scales.
Owner
- Name: Elio Campitelli
- Login: eliocamp
- Kind: user
- Location: Melbourne, Australia
- Repositories: 160
- Profile: https://github.com/eliocamp
Research Fellow at Monash University
GitHub Events
Total
- Create event: 2
- Release event: 1
- Issues event: 3
- Watch event: 25
- Issue comment event: 9
- Push event: 16
- Pull request event: 1
Last Year
- Create event: 2
- Release event: 1
- Issues event: 3
- Watch event: 25
- Issue comment event: 9
- Push event: 16
- Pull request event: 1
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Elio Campitelli | e****i@g****m | 182 |
| Teun van den Brand | 4****d | 2 |
| olivroy | 5****y | 1 |
Issues and Pull Requests
Last synced: 7 months ago
All Time
- Total issues: 70
- Total pull requests: 4
- Average time to close issues: 3 months
- Average time to close pull requests: 12 days
- Total issue authors: 44
- Total pull request authors: 3
- Average comments per issue: 2.8
- Average comments per pull request: 3.25
- Merged pull requests: 3
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 7
- Pull requests: 1
- Average time to close issues: 4 days
- Average time to close pull requests: 2 days
- Issue authors: 3
- Pull request authors: 1
- Average comments per issue: 0.86
- Average comments per pull request: 7.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- eliocamp (17)
- willgearty (4)
- mattansb (3)
- raymondben (3)
- PursuitOfDataScience (2)
- Drosof (2)
- Maschette (2)
- dschlaep (1)
- janstrauss1 (1)
- ArturLourenco (1)
- acpguedes (1)
- laura-martinez00 (1)
- gogonzo (1)
- A-Zalesak (1)
- owenssam1 (1)
Pull Request Authors
- teunbrand (3)
- jonthegeek (1)
- olivroy (1)
Top Labels
Issue Labels
bug (1)
invalid (1)
reprex-needed (1)
Pull Request Labels
Dependencies
DESCRIPTION
cran
- ggplot2 >= 3.0.0 imports
- covr * suggests
- testthat * suggests
- vdiffr * suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/cache v2 composite
- actions/checkout v2 composite
- actions/upload-artifact main composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v1 composite
.github/workflows/pkgdown.yaml
actions
- JamesIves/github-pages-deploy-action v4.4.1 composite
- actions/checkout v3 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v1 composite