我在 ggplot 图中有一个从白色到红色的颜色条,并且白色边框在白色背景上不太明显。
有没有办法对图例中的刻度线进行不同的着色或在渐变比例周围添加边框?
这是一个最小的例子:
df <- data.frame(x <- rnorm(10),
y <- rnorm(10),
fill <- rnorm(10))
ggplot(df, aes(x, y, fill = fill)) +
geom_point() +
scale_fill_gradient(low = 'white', high = 'red')
在最新的 ggplot2(开发版本,将作为 2.3 发布)中,现在可以使用:
# devtools::install_github("tidyverse/ggplot2") # do this once
library(ggplot2)
df <- data.frame(x <- rnorm(10),
y <- rnorm(10),
fill <- rnorm(10))
ggplot(df, aes(x, y, fill = fill)) +
geom_point() +
scale_fill_gradient(low = 'white', high = 'red',
guide = guide_colorbar(frame.colour = "black", ticks.colour = "black"))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)