Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scale_colour_stepsn does not work with trans of "reverse" or c("log10", "reverse") #389

Closed
davidhodge931 opened this issue Jul 19, 2023 · 1 comment

Comments

@davidhodge931
Copy link

library(tidyverse)
library(scales)  
#> Warning: package 'scales' was built under R version 4.3.1
#> 
#> Attaching package: 'scales'
#> The following object is masked from 'package:purrr':
#> 
#>     discard
#> The following object is masked from 'package:readr':
#> 
#>     col_factor
p <- pressure |>
  ggplot() +
  geom_point(
    aes(
      x = temperature, , 
      y = pressure,
      col = pressure,
    ))

# p + scale_colour_gradientn(colors = viridis::viridis(10), trans = "identity")
# p + scale_colour_gradientn(colors = viridis::viridis(10), trans = "log10")
# p + scale_colour_gradientn(colors = viridis::viridis(10), trans = "reverse")
# p + scale_colour_gradientn(colors = viridis::viridis(10), trans = c("log10", "reverse"))
# 
# p + scale_colour_stepsn(colors = viridis::viridis(10), trans = "identity")
# p + scale_colour_stepsn(colors = viridis::viridis(10), trans = "log10")
p + scale_colour_stepsn(colors = viridis::viridis(10), trans = "reverse")

p + scale_colour_stepsn(colors = viridis::viridis(10), trans = c("log10", "reverse"))

Created on 2023-07-19 with reprex v2.0.2

@davidhodge931 davidhodge931 changed the title scale_colour_stepsn does not work with trans of "reverse" or c("log10", "reverse") scale_colour_stepsn does not work with trans of "reverse" or c("log10", "reverse") Jul 19, 2023
@teunbrand
Copy link
Contributor

I think this is a fallout from the upstream issue that binned scales don't deal with trans = "reverse" very well, which should probably be resolved in ggplot2.

library(ggplot2)
ggplot(mtcars) +
  geom_bar(aes(mpg)) +
  scale_x_binned(trans = "reverse")

Created on 2023-07-19 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants