legendry

A 'ggplot2' extension that focusses on expanding the plotter's arsenal of guides, such as axes, legends and colour bars. It brings various improvements to existing guides by re-implementation, as well as adding novel guides.

https://github.com/teunbrand/legendry

Science Score: 26.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
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (19.8%) to scientific vocabulary

Keywords

axis axis-customization ggplot-extension ggplot2 legend r r-package visualization
Last synced: 6 months ago · JSON representation

Repository

A 'ggplot2' extension that focusses on expanding the plotter's arsenal of guides, such as axes, legends and colour bars. It brings various improvements to existing guides by re-implementation, as well as adding novel guides.

Basic Info
Statistics
  • Stars: 254
  • Watchers: 5
  • Forks: 7
  • Open Issues: 8
  • Releases: 5
Topics
axis axis-customization ggplot-extension ggplot2 legend r r-package visualization
Created almost 4 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog License Code of conduct

README.Rmd

---
output: github_document
---



```{r}
#| include: false
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "80%",
  dev = "svglite",
  dev.args = list(fix_text_size = FALSE),
  dpi = 132,
  fig.align = "center"
)
```

# legendry legendry website


[![R-CMD-check](https://github.com/teunbrand/legendry/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/teunbrand/legendry/actions/workflows/R-CMD-check.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/legendry)](https://www.r-pkg.org/badges/version/legendry)
[![Codecov test coverage](https://codecov.io/gh/teunbrand/legendry/graph/badge.svg)](https://app.codecov.io/gh/teunbrand/legendry)


The goal of legendry is to provide additional guide functionality to the ggplot2 ecosystem.

## Installation

You can install the development version of legendry from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("teunbrand/legendry")
```

## Example

Let's first set up a basic plot to experiment with:

```{r}
#| label: basic_plot
library(legendry)

base <- ggplot(mpg, aes(displ, hwy, colour = cty)) +
  geom_point() +
  labs(
    x = "Engine displacement",
    y = "Highway miles per gallon",
    col = "City miles\nper gallon"
  ) +
  theme(axis.line = element_line())
```

The legendry package offers a selection of what it calls 'complete guides'. 
These complete guides can just be drop-in replacement of regular guides, which you can specify using ggplot2's `guides()` function or using the `guide` argument in scales.
In the example below, we're using two custom variants of vanilla guides, namely `guide_axis_base()` and `guide_colbar()`. These custom variants have additional options that allow a greater degree of customisation: 

* The axis guide has an option for bidirectional ticks.
* The colourbar automatically recognises out-of-bounds values and displays this with a cap.

```{r}
#| label: full_guides
base + 
  scale_colour_viridis_c(
    limits = c(NA, 30),
    guide = "colbar"
  ) +
  guides(
    x = guide_axis_base(bidi = TRUE)
  )
```

Besides complete guides, legendry also has incomplete guides that can be composed.
The `ggplot2::guide_axis_stack()` is an axis composition function that can be used to display multiple guides.
Here, we use a 'primitive' guide (incomplete building block) to display a range on the axis.
By stacking it with a regular axis the primitive guide is completed.

```{r}
#| label: primitives
# A partial guide to display a bracket
efficient_bracket <- primitive_bracket(
  # Keys determine what is displayed
  key = key_range_manual(start = 25, end = Inf, name = "Efficient"),
  bracket = "square",
  # We want vertical text
  theme = theme(
    legend.text = element_text(angle = 90, hjust = 0.5),
    axis.text.y.left = element_text(angle = 90, hjust = 0.5)
  )
)

base + guides(y = guide_axis_stack("axis", efficient_bracket))
```

The legendry package extends this guide composition concept beyond the axes for other types of guides.
In the example below we compose a 'sandwich': a central guide flanked by two others.
Because our bracket is a primitive, it does not matter what aesthetic it displays and we can re-use it for the sandwich.
I've yet to write the vignette on composition.

```{r}
#| label: composition
base + 
  scale_colour_viridis_c(
    guide = compose_sandwich(
      middle = gizmo_density(), 
      text = "axis_base",
      opposite = efficient_bracket
    )
  )
```

## Code of Conduct

Please note that the legendry project is released with a [Contributor Code of Conduct](https://teunbrand.github.io/legendry/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.

Owner

  • Name: Teun van den Brand
  • Login: teunbrand
  • Kind: user
  • Location: Amsterdam
  • Company: Netherlands Cancer Institute

Computational PhD student in @deWitLab with an interest in chromatin biology and gene regulation.

GitHub Events

Total
  • Create event: 23
  • Release event: 4
  • Issues event: 63
  • Watch event: 117
  • Delete event: 18
  • Issue comment event: 71
  • Push event: 93
  • Pull request event: 35
  • Fork event: 2
Last Year
  • Create event: 23
  • Release event: 4
  • Issues event: 63
  • Watch event: 117
  • Delete event: 18
  • Issue comment event: 71
  • Push event: 93
  • Pull request event: 35
  • Fork event: 2

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 180
  • Total Committers: 3
  • Avg Commits per committer: 60.0
  • Development Distribution Score (DDS): 0.017
Past Year
  • Commits: 73
  • Committers: 3
  • Avg Commits per committer: 24.333
  • Development Distribution Score (DDS): 0.041
Top Committers
Name Email Commits
Teun van den Brand t****d@g****m 177
Luis Verde Arregoitia l****d@c****x 2
Michael Thomas 5****k 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 57
  • Total pull requests: 39
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 2 days
  • Total issue authors: 21
  • Total pull request authors: 3
  • Average comments per issue: 1.81
  • Average comments per pull request: 0.05
  • Merged pull requests: 37
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 44
  • Pull requests: 38
  • Average time to close issues: 10 days
  • Average time to close pull requests: 2 days
  • Issue authors: 17
  • Pull request authors: 3
  • Average comments per issue: 1.32
  • Average comments per pull request: 0.05
  • Merged pull requests: 36
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • teunbrand (23)
  • Breeze-Hu (4)
  • dominicroye (2)
  • DanChaltiel (2)
  • xtimbeau (2)
  • carnivoreberry (1)
  • gkaramanis (1)
  • sebastian-gregoricchio (1)
  • greengeckoruns (1)
  • KGZaker (1)
  • mayerbry (1)
  • corybrunson (1)
  • mkramer77 (1)
  • luisDVA (1)
  • yjunechoe (1)
Pull Request Authors
  • teunbrand (40)
  • luisDVA (3)
  • mthomas-ketchbrook (1)
Top Labels
Issue Labels
:bug: bug (4) :bulb: feature (3) :broken_heart: invalid (2) :memo: documentation (2) feature (1)
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • cran 1,432 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 0
    (may contain duplicates)
  • Total versions: 10
  • Total maintainers: 1
proxy.golang.org: github.com/teunbrand/legendry
  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
cran.r-project.org: legendry

Extended Legends and Axes for 'ggplot2'

  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 1,432 Last month
Rankings
Dependent packages count: 27.9%
Dependent repos count: 34.3%
Average: 49.7%
Downloads: 86.9%
Maintainers (1)
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • ggplot2 * depends
  • glue * imports
  • grid * imports
  • gtable * imports
  • lifecycle * imports
  • rlang * imports
  • scales * imports
  • stats * imports
  • utils * imports
  • vctrs * imports
  • covr * suggests
  • testthat >= 3.0.0 suggests
  • vdiffr * suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 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 v3 composite
  • actions/upload-artifact v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 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