【发布时间】:2020-01-30 21:09:54
【问题描述】:
我想在绘图注释中显示形状值(geom_point 函数的shape 参数)。
例如,在下面,我只是写'point shape',我实际上希望显示形状本身。 (这是我想做的更复杂的事情的一个最小示例。)
有没有办法做到这一点?
library(ggplot2)
ggplot(mtcars, aes(mpg , wt)) + geom_point(shape = 7) +
labs(title = "'point shape' represents data point")
由reprex package (v0.3.0.9001) 于 2020 年 1 月 30 日创建
【问题讨论】:
-
不知道我是否理解正确。所以像 ggplot(mtcars,aes(mpg,wt)) + geom_text(aes(label=cyl)) ?你在哪里显示 cyl 的值?
-
一种可能性是添加
annotate("point", x, y, shape = 7)之类的内容,然后添加另一个annotate("text", x, y, label = "represents...", hjust = 0)和x和y是您希望文本/符号出现的坐标(可能在情节之外如果需要也可以)