Skip to content

binned_scale() function missing after version 3.4.1? #5942

Closed
@schmittrjp

Description

@schmittrjp

I have a lot of code that uses binned color scales similar to what was described in https://stackoverflow.com/questions/66318404/how-to-use-specific-filling-colors-when-using-scale-fill-binned/78614646#78614646

The reprex below is mostly taken from the thread on StackOverflow. Basically, the idea is to define exact colors for binned color scales.

This works well on ggplot v3.4.x.

Now I upgraded to 3.5.1 and I get an error

Error in list2(...) : object binned_scale not found

It seems like the function binned_scale is not a part of ggplot anymore. Has binned_scale been retired?

library(tidyverse)

dat <- mtcars %>% 
  group_by(cyl) %>% 
  summarise(n = n(),
            mean_hp = mean(hp)) %>% 
  ungroup

cols <- c("red", "blue", "grey50", "black")
ggplot(data = dat, aes(x = cyl, y = mean_hp, size = n, fill = n)) +
  geom_point(shape = 21) +
  scale_size_binned(breaks = c(8, 10, 12), guide = guide_bins(show.limits = T)) +
  labs(x = "Cylinder", y = "Mean hp", fill = "Nb of cars", size = "Nb of cars") +
  theme_minimal() +
  binned_scale(aesthetics = "fill", scale_name = "custom", 
               palette = ggplot2:::binned_pal(scales::manual_pal(values = cols)),
               guide = "bins",
               breaks = c(8, 10, 12), limits = c(min(dat$n), max(dat$n)), show.limits = T)

Created on 2024-06-12 with reprex v2.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions