Comments (4)
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.
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.
Good to know! Do report any other issue, though.
from ggnewscale.
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
-
Normally, one wouldn't include
guide = guide_colorsteps()
inscale_color_stepsn
, as it is the default behavior; however, in my non-reprex usage I sometimes setguide = "legend"
:guide = if (diff(lengths(list(params$labels, params$breaks))) == 1) "legend" else guide_colorsteps()
↩
from ggnewscale.
Related Issues (20)
- Multiple new_scale_fill doesn't work. HOT 10
- Support for plotly HOT 4
- Release ggnewscale 0.4.8
- Issue When Trying to Employ `guide_colourbar` ::::: v0.4.8 HOT 5
- Legend issues when using `guides(...)` HOT 4
- Add ability to name scales HOT 7
- ggnewscale CRAN note HOT 3
- Issues with next version of ggplot2 HOT 4
- Question on overriding scales on a pre-existing ggnewscale plot HOT 3
- Release ggnewscale 0.4.9
- Release ggnewscale 0.4.10
- new_scale_colour does not work with a scale_* function that includes a guide argument HOT 4
- `guide` vs. `show.legend` with `new_scale()` HOT 4
- Does not display two scales HOT 2
- Release ggnewscale 0.5.0
- Release ggnewscale 0.4.10 HOT 4
- New Scales Clear Custom Attributes HOT 2
- setting legend name in `guides` vs. in `scale_manual` with `new_scale()` HOT 1
- Consider implementing guides with custom hastables HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ggnewscale.