Git Product home page Git Product logo

Comments (4)

martinherrerias avatar martinherrerias commented on July 27, 2024

These seem to work:

ggplot() + scale_x_reverse(limits = c(10,1))
ggplot() + scale_x_continuous(limits = c(10,1), transform = scales::transform_reverse())

These (also) don't:

ggplot() + scale_x_reverse(limits = c(1,10))
ggplot() + scale_x_continuous(limits = c(1,10), transform = scales::transform_reverse())

from ggplot2.

teunbrand avatar teunbrand commented on July 27, 2024

Strange, I don't think I've encountered this before.
Is flipping the limits supposed to give a reversed scale?
I'm having trouble tracing where this is documented.

from ggplot2.

tombishop1 avatar tombishop1 commented on July 27, 2024

Hmm, its a method that has been passed around, although now you mention it I actually don't know whether it is officially supported. The method described in Chang's "The R Graphics Cookbook", when one needs to both reverse an axis and set it's range is as follows:

ggplot() + scale_x_reverse(limits = c(10,1))

This does work.

from ggplot2.

teunbrand avatar teunbrand commented on July 27, 2024

It sort of makes sense that this works for scale_x_reverse() somehow, as limits get transformed straight away in the scale, so that'd yield effectively limits = c(-10, -1) in transformed space. Invoking transform = "reverse" by having inverse limits sounds tricky to me.

I think that probably the most consistent thing to do is always have sorted limits internally, so that it shouldn't matter if you put limits = c(10, 1) or limits = c(1, 10). That'd also sort out the axis breaks not showing up.

from ggplot2.

Related Issues (20)

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.