Git Product home page Git Product logo

teunbrand / gguidance Goto Github PK

View Code? Open in Web Editor NEW
82.0 82.0 3.0 14.59 MB

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.

Home Page: https://teunbrand.github.io/gguidance/

License: Other

R 100.00%
axis axis-customization ggplot-extension ggplot2 legend r r-package visualization

gguidance's People

Contributors

teunbrand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gguidance's Issues

A cap of legend in fill scale

Hi, I am trying to use this guide_colourbar_cap function, but I cannot find a way to use it in the fill scale, guides(fill = guide_colourbar_cap()) does not work. Could you please share an example, thank you.

Cannot install it

> R.version
               _                           
platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          4                           
minor          3.2                         
year           2023                        
month          10                          
day            31                          
svn rev        85441                       
language       R                           
version.string R version 4.3.2 (2023-10-31)
nickname       Eye Holes 

> packageVersion("ggplot2")
[1] ‘3.4.4.9000’

I followed the instructions on the README, but I get the following error (I guess because of the specification in the DESCRIPTION file...):

> pak::pak("teunbrand/gguidance@main")
Error:                                                               
! error in pak subprocess
Caused by error: 
! Could not solve package dependencies:
* teunbrand/gguidance@main: Can't install dependency tidyverse/ggplot2#4879 (>= 3.4.2.9000)
* tidyverse/ggplot2#4879: ! pkgdepends resolution error for tidyverse/ggplot2#4879.
Caused by error: 
! no such index at level 5

Type .Last.error to see the more details.
> .Last.error
<callr_error/rlib_error_3_0/rlib_error/error>
Error: 
! error in pak subprocess
Caused by error: 
! Could not solve package dependencies:
* teunbrand/gguidance@main: Can't install dependency tidyverse/ggplot2#4879 (>= 3.4.2.9000)
* tidyverse/ggplot2#4879: ! pkgdepends resolution error for tidyverse/ggplot2#4879.
Caused by error: 
! no such index at level 5

---
Backtrace:
1. pak::pak("teunbrand/gguidance@main")
2. pak::pkg_install(pkg, ...) at pak.R:30:5
3. pak:::remote(function(...) get("pkg_install_make_plan", asNamespace("pak"))(...), … at package.R:76:3
4. err$throw(res$error) at subprocess.R:125:5
---
Subprocess backtrace:
1. base::withCallingHandlers(cli_message = function(msg) { …
2. get("pkg_install_make_plan", asNamespace("pak"))(...)
3. prop$stop_for_solution_error() at package.R:103:3
4. private$plan$stop_for_solve_error()
5. pkgdepends:::pkgplan_stop_for_solve_error(self, private)
6. base::throw(new_error("Could not solve package dependencies:\n", msg, …
7. | base::signalCondition(cond)
8. global (function (e) …
There were 12 warnings (use warnings() to see them)

`guide_coloursteps_custom` does not respect `theme(legend.ticks = ...))`

library(gguidance)
library(tidyverse)
library(palmerpenguins)

ggplot(mpg, aes(displ, hwy, colour = cty)) +
  geom_point() +
  labs(
    x = "Engine displacement",
    y = "Highway miles per gallon",
    col = "City miles\nper gallon"
  ) +
  theme(legend.ticks = element_line(colour = "red")) +
  guides(colour = guide_coloursteps_custom()) 

image

legends for colour & fill not merging with guide_custom

Awesome new package - great work!

Minor thing I noticed was the legends for colour & fill were not merging with guide_custom

library(gguidance)
library(tidyverse)
library(palmerpenguins)

penguins |>
  group_by(species) |>
  summarise(across(flipper_length_mm, \(x) mean(x, na.rm = TRUE))) |>
  ggplot() +
  geom_col(
    aes(x = flipper_length_mm,
    y = species,
    colour = flipper_length_mm,
    fill = flipper_length_mm)) +
  guides(
    colour = guide_colourbar_custom(),
    fill = guide_colourbar_custom(),
  ) 

image

Better names for functions ending in `_custom()`

I'm discontent with the name of some function that end in the _custom() suffix.
Famously, naming things is one of the harder things to do in programming.
I'd gladly entertain alternative names for these.

Currently, it concerns the following functions:

  • guide_axis_custom()
  • guide_colourbar_custom()
  • guide_coloursteps_custom()

guide_colourbar_custom throws error with theme(legend.key.spacing = NULL)

library(gguidance)
#> Loading required package: ggplot2
library(tidyverse)
library(palmerpenguins)

penguins |>
  group_by(species) |>
  summarise(across(flipper_length_mm, \(x) mean(x, na.rm = TRUE))) |>
  ggplot() +
  geom_col(
    aes(x = flipper_length_mm,
        y = species,
        colour = flipper_length_mm)) +
  guides(colour = guide_colourbar_custom()) +
  theme(legend.key.spacing = NULL)
#> Error in as.unit(e2): object is not coercible to a unit

Created on 2024-04-26 with reprex v2.1.0

guide_colourbar_custom can't handle ticks with 2 elements

library(gguidance)
#> Loading required package: ggplot2
library(tidyverse)
library(palmerpenguins)

penguins |>
  ggplot() +
  geom_point(
    aes(x = flipper_length_mm,
        y = species,
        colour = flipper_length_mm)) +
  guides(
    colour = guide_colourbar_custom(),
  ) +
  theme(legend.ticks.length = ggplot2::rel(c(0.15, 0)))
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_point()`).
#> Warning in gizmo_barcap(): Unable to check the capabilities of the png device.
#> Error in n_breaks < 1 || is_blank(element) || length == 0: 'length = 2' in coercion to 'logical(1)'

Created on 2024-04-27 with reprex v2.1.0

Suggestion: Excel-style grouped axes

Excel has really nice support for 'grouped' axes like the following:
excel-grouped-axis

Currently a similar effect would be achievable using bracketed ranges, but I wonder if it's worth considering a dedicated feature, e.g. which would allow the user to specify columns to use for the inner/outer axis levels, and perhaps render the results similarly to Excel (instead of simply being an alternative API for bracketed ranges).

Discussion on Fosstodon: https://fosstodon.org/@teunbrand/111839196732828384

Really excited to find out about this package - looks like an amazing addition to the ggplot2 extensions ecosystem :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.