Giter VIP home page Giter VIP logo

Comments (4)

eliocamp avatar eliocamp commented on August 17, 2024

This is supposed to be fixed by #57, which is included in the latest release. All tests pass with the current ggplot2 version. Make sure you're running the latest ggnewscale version. If the problem persists, please submit a reproducible example so I can investigate further.

from ggnewscale.

alhenry avatar alhenry commented on August 17, 2024

I've tested with the latest version of ggplot2 and ggnewscale on CRAN and no longer found the issue. Will close this for now. Sorry for the false alarm!

from ggnewscale.

eliocamp avatar eliocamp commented on August 17, 2024

Good to know! Do report any other issue, though.

from ggnewscale.

bennotkin avatar bennotkin commented on August 17, 2024

Edit: I wrote all of this and then realized the ggplot 3.5 now allows for guide = "colorsteps", not just guide = guide_colorsteps(). With the former, I get the desired behavior. Editing, rather than deleting, this comment for anyone who may find this helpful.


I continue to have the same error, when I set guide = guide_colorsteps().

Here's a reproducible example:

ggplot(mpg) +
  geom_point(aes(x = cty, y = hwy, color = displ)) +
  scale_color_stepsn(
    colors = c("yellow", "red"),
    guide = guide_colorsteps()) +
  ggnewscale::new_scale_color()
# Error in scale$guide == "none" : 
#   comparison (==) is possible only for atomic and list types

I don't get the error if I don't include guide = guide_colorsteps()1, nor if `guide = "legend". Both of the following work:

ggplot(mpg) +
  geom_point(aes(x = cty, y = hwy, color = displ)) +
  scale_color_stepsn(colors = c("yellow", "red")) +
  ggnewscale::new_scale_color()

ggplot(mpg) +
  geom_point(aes(x = cty, y = hwy, color = displ)) +
  scale_color_stepsn(
    colors = c("yellow", "red"),
    guide = "legend") +
  ggnewscale::new_scale_color()

If, rather than setting the guide in scale_color_stepsn but in guides(), there is no error with ggnewscale::new_scale_color(), but the guide setting persists after ggnewscale::new_scale_color(), and that causes a different error when the guide type is different in the next plot:

ggplot(mpg) +
  geom_point(aes(x = cty, y = hwy, color = displ)) +
  scale_color_stepsn(colors = c("yellow", "red")) +
  guides(color = guide_colorsteps()) +
  ggnewscale::new_scale_color() +
  # Shifting x and y so they are obviously separate from previous layer
  geom_point(aes(x = cty + 10, y = 50 - hwy, color = class), shape = 1)
# Error in `parse_binned_breaks()`:
# ! Breaks are not formatted correctly for a bin legend.
# ℹ Use `(<lower>, <upper>]` format to indicate bins.
# Run `rlang::last_trace()` to see where the error occurred.
# Warning message:
# In parse_binned_breaks(scale, breaks) : NAs introduced by coercion

Footnotes

  1. Normally, one wouldn't include guide = guide_colorsteps() in scale_color_stepsn, as it is the default behavior; however, in my non-reprex usage I sometimes set guide = "legend": guide = if (diff(lengths(list(params$labels, params$breaks))) == 1) "legend" else guide_colorsteps()

from ggnewscale.

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.