Skip to content

Easy way to reverse palette? #299

Open

Description

@grantmcdermott

I might be missing an obvious workaround, but I've encountered a few situations where I'd like an easy way to reverse the colour palette. For example, the colours of the "temps" HCL palette are running in the "wrong" direction here:

library(tinyplot)

plt(Month ~ Temp, airquality, type = type_ridge(gradient = "temps"))

Created on 2025-02-03 with reprex v2.1.1

Activity

  1. grantmcdermott commented on Feb 3, 2025

    @grantmcdermott
    OwnerAuthor

    One workaround is manually specifying the palette and passing the rev = TRUE argument. But it isn't particularly convenient.

    library(tinyplot)
    plt(Month ~ Temp, airquality, type = type_ridge(gradient = TRUE),
        palette = hcl.colors(n = 100, palette = "temps", rev = TRUE))

    Created on 2025-02-03 with reprex v2.1.1

  2. zeileis commented on Feb 3, 2025

    @zeileis
    Collaborator

    I couldn't find it in the issues but I vaguely recall that we had a similar discussion about a convenience option for dropping the first color in a palette (which is often useful if the first color is black). But we didn't go for it because it was already possible by passing a vector of colors to palette.

    I'm not completely sure, though, whether I remember this correctly...

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions