我试图使我的绘图灰度;尝试使用scale_color_greyscale而不是viridis,但是我得到了一个错误,上面写着“提供给离散比例的连续值”。不过,我的“距离”变量是连续的
geom_sf(data = df, aes(color = distance),
lwd = 0.1, alpha = 0.3)+
scale_color_viridis(breaks = c(20, 40, 60))发布于 2022-05-25 07:56:04
我不确定您的数据和预期结果,但是灰比例尺有scale_fill_grey和scale_fill_gradient2。
scale_fill_grey (https://ggplot2.tidyverse.org/reference/scale_grey.html)
scale_colour_grey(
...,
start = 0.2,
end = 0.8,
na.value = "red",
aesthetics = "colour"
)scale_fill_gradient (https://ggplot2.tidyverse.org/reference/scale_gradient.html)
参考StackOverflow文章:heatplot ggplot2 error different behaviour between scale_fill_gradient2 and scale_fill_grey Error: Continuous value supplied to discrete scale
scale_colour_gradient(
...,
low = "white",
high = "black",
space = "Lab",
na.value = "grey50",
guide = "colourbar",
aesthetics = "colour"
)与其使用scale_color_viridis,不如尝试它们。
https://stackoverflow.com/questions/72371968
复制相似问题