使用形状时缺少 geom_point 的绘图符号

Vij*_*uri 4 r ggplot2

我显然错过了一些简单的东西,或者这是一个小错误。当使用 shape=factor 时,geom_point () 总是缺少绘图符号。当使用 color=factor 时,不会发生这种情况。感谢你的帮助。这是一个测试代码。

test <- data.frame(let=sample(LETTERS,7), id=c(1:7), y=c(id*7))

ggplot(data=test, aes(x=id, y=y))+
geom_point(aes(shape=let), size=6)
Run Code Online (Sandbox Code Playgroud)

“请注意这里缺少的点(7 个中只有 6 个),因为缺少一个符号,这通常是按字母顺序排列的最后一个因素”

ggplot(data=test, aes(x=id, y=y))+
geom_point(aes(color=let), size=6)
Run Code Online (Sandbox Code Playgroud)

“这里我们看到 7 个不同颜色的点”

谢谢,VJ

bap*_*ste 5

这是因为scales::shape_pal最多定义 6 个值;尝试添加scale_shape_manual(values=1:7)