我想独立使用色标,即连续和分类比例。ggplot2 - 使用不同类型的色标
我心里有一个特定的应用程序,其中我有一个简单的情节像这里
mtcars %>%
mutate(cylcol = factor(if_else(cyl == 6, "six", "not six"))) %>%
ggplot(aes(x = mpg, y = wt)) +
geom_point(aes(color = drat)) +
facet_wrap(~ cyl)
但我也想highlight border, like in the answer of Seth_P, of a specific condition(我dont't想用填充面的背景!)。例如
mtcars %>%
mutate(cylcol = factor(if_else(cyl == 6, "six", "not six"))) %>%
ggplot(aes(x = mpg, y = wt)) +
geom_point() +
geom_rect(xmin = -Inf, xmax = Inf, show.legend = FALSE,
ymin = -Inf, ymax = Inf, aes(col = cylcol), fill = "#00000000") +
facet_wrap(~ cyl)
现在我想以 “合” 这两个,像例如:
mtcars %>%
mutate(cylcol = factor(if_else(cyl == 6, "six", "not six"))) %>%
ggplot(aes(x = mpg, y = wt)) +
geom_point(aes(color = drat)) +
geom_rect(xmin = -Inf, xmax = Inf, show.legend = FALSE,
ymin = -Inf, ymax = Inf, aes(col = cylcol), fill = "#00000000") +
facet_wrap(~ cyl)
这就产生了一个错误Error: Discrete value supplied to continuous scale
。这使得一方面感觉到,但另一方面,因为两者都使用自变量,所以我想使用“不同的颜色比例”。我可以使用覆盖图,如here, where facet colors are plotted over the plot,但我会非常感谢一个更简单的解决方案。我知道specifying fill and color separately - 但这不是目标。我真的想在不同的尺度上使用颜色。有什么建议么 ?
谢谢。在这篇文章中,我已经写道,我知道使用填充和颜色电子音。但是,在我的实际情节中(这里没有显示),我已经使用填充来填充其他类型的信息。此解决方法也可以工作,但对我无效。 – Drey
对不起@Drey。我知道你知道单独的美学,只是人们常常不知道'geom_point'的一些形状使用填充颜色而不是颜色。 –