Closed danlooo closed 2 years ago
Thanks for the issue. This is fixed now on the development version of the package (devtools::install_github("eliocamp/ggnewscale@dev").
library(ggplot2)
library(ggnewscale)
packageVersion("ggnewscale")
#> [1] '0.4.5.9000'
ggplot(head(iris, 10), aes(Sepal.Length, Sepal.Width)) +
geom_point(aes(color = factor(Petal.Length))) +
guides(color = guide_legend(ncol = 2, nrow = 2)) +
new_scale_colour() +
geom_point(aes(color = factor(Petal.Width))) +
guides(color = guide_legend(ncol = 1, nrow = 4))
As a workaround in the current CRAN version you can define guides inside scales to get the expected behaviour.
ggplot(head(iris, 10), aes(Sepal.Length, Sepal.Width)) +
geom_point(aes(color = factor(Petal.Length))) +
scale_color_discrete(guide = guide_legend(ncol = 2, nrow = 2)) +
new_scale_colour() +
geom_point(aes(color = factor(Petal.Width))) +
scale_color_discrete(guide = guide_legend(ncol = 1, nrow = 4))
Created on 2022-02-15 by the reprex package (v2.0.1)
The update is now on CRAN.
Hello,
thanks for developing such a useful package! It seems that
ggnewscale::scale_new_color
overwrites parameters ofggplot2::guides
, when they were written before the creation of the new scale. I was able to fix this by usingcolor_new
instead ofcolor
in functionguides
after the creation of the new scale. Is this intended behavior? For me, it is a little confusing that former parameters are not preserved.Created on 2022-02-15 by the reprex package (v2.0.0)