我正在尝试为 ggplot2 中的散点图上的所有点分配一种颜色。但是,无论我将 fill =
设置为什么颜色,这些点最终总是变成黑色。
这是我的代码(带有虚拟变量):
ggplot(data = testDF) +
geom_point(aes(x = testDF$X, y = testDF$Y),
fill = "#2EC4B6", color = "#E71D36") # Fill is cyan, color is red
剧情是这样的:
最佳答案
geom_point
使用的默认形状没有fill
美学。您可以通过更改 shape
参数来解决此问题:
ggplot( mtcars, aes( x = wt, y = mpg ) ) +
geom_point( shape = 21, fill = "#2EC4B6", color = "#E71D36" )
关于r - 即使指定,散点图填充在 ggplot2 中也不会改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45376877/