ggplot中的自定义形状(geom_point)

用户名

目标

我正在尝试将的形状更改geom_point为十字形(所以不是“加/加”符号,而是“死亡”十字形)。

尝试

假设我有以下数据:

library(tidyverse)

df <- read.table(text="x y
                 1    3 
                 2    4 
                 3    6 
                 4    7 ", header=TRUE) 

我可以使用shape参数将形状更改geom_point为不同的形状,如下所示:

ggplot(data = df, aes(x =x, y=y)) +  
   geom_point(shape=2)   # change shape

但是,没有选择将形状更改为十字形的选项。

如何在R中使用ggplot将值的形状更改为十字形?

27 ϕ 9

形状可以设置为unicode字符。下面使用骷髅和交叉骨,但您可以查找更合适的符号。

请注意,最终结果将取决于用于生成图的字体。

ggplot(data = df, aes(x =x, y=y)) +  
  geom_point(shape="\u2620", size = 10) 

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章