You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
library(ggplot2)
library(ggnewscale)
# Equivalent to melt(volcano)topography<- expand.grid(x=1:nrow(volcano),
y=1:ncol(volcano))
topography$z<- c(volcano)
# point measurements of something at a few locations
set.seed(42)
measurements<-data.frame(x= runif(30, 1, 80),
y= runif(30, 1, 60),
thing= rnorm(30))
ggplot(mapping= aes(x, y)) +
geom_contour(data=topography, aes(z=z, color= stat(level))) +
scale_x_continuous(limits= c(25, 75)) +# Color scale for topography
scale_color_viridis_c(option="D") +# geoms below will use another color scale
new_scale_color() +
geom_point(data=measurements, size=3, aes(color=thing)) +# Color scale applied to geoms added after new_scale_color()
scale_color_viridis_c(option="A")
it breaks and gives the following error: Error in get(as.character(FUN), mode = "function", envir = envir) : object 'guide_none' of mode 'function' was not found
Based on the error, I believe I've tracked down the problem to this line of code. After messing around with some ggplot objects, it looks like these particular scales don't have guides, so the names of the guides are "none", which is still a character, so it proceeds but doesn't find any function guide_none().
I think all you would need to do is change the if statement here to if (is.character(scale$guide) & !(scale$guide == "none")) { but I'm actually not sure if this would break anything else. If I get a chance, I'll fork and try it out.
The text was updated successfully, but these errors were encountered:
It seems that the problem is that new_scale() is changing the x scale when it's not supposed to. Putting scale_x_continuous(limits = c(25, 75)) after new_scale() is a workaround.
The example in the readme works fine for me, but as soon as I introduce any function of the scale_continuous family or scale_discrete family like this:
it breaks and gives the following error:
Error in get(as.character(FUN), mode = "function", envir = envir) : object 'guide_none' of mode 'function' was not found
Based on the error, I believe I've tracked down the problem to this line of code. After messing around with some ggplot objects, it looks like these particular scales don't have guides, so the names of the guides are "none", which is still a character, so it proceeds but doesn't find any function
guide_none()
.I think all you would need to do is change the if statement here to
if (is.character(scale$guide) & !(scale$guide == "none")) {
but I'm actually not sure if this would break anything else. If I get a chance, I'll fork and try it out.The text was updated successfully, but these errors were encountered: