Skip to content

Unsorted breaks in guide_coloursteps() #5152

Description

@teunbrand

guide_coloursteps() and guide_bins() seems to give incorrect guide when breaks are not sorted in increasing direction.

In the example below, we can see the coloursteps aren't right. The same happens with continuous scales, but binned scales come with coloursteps by default, so that reprex was more minimal. This doesn't only happen when the breaks are sorted in descending order as in the example below, but this generally seems to happen when they're not increasing.

library(ggplot2)

p <- ggplot(mpg, aes(displ, hwy, colour = cty)) +
  geom_point()

p + scale_colour_viridis_b(breaks = seq(30, 10, by = -5))

You'd expect the guide to look like this:

p + scale_colour_viridis_b(breaks = seq(10, 30, by = 5))

Created on 2023-01-18 with reprex v2.0.2

I think the fix would be a simple sorting step in the guide training.

Activity

  1. added
    bug
    on Jan 18, 2023
  2. added a commit that references this issue on Jan 18, 2023
    80da767
  3. added a commit that references this issue on Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugguides 📏

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions