R语言-ggplot自定义点的形状汇总
一、ggpubr包
library(ggplot2)
library(ggpubr)
show_point_shapes() #显示点的形状(ggpubr包内的函数)
使用方法:
其中的形状21-25是可以设置填充颜色和描边颜色的,fill代表填充颜色,colour代表描边的颜色。可以设置为NA代表没有
# 随机生成数据
set.seed(123)
df <- data.frame(x = rnorm(30), y = rnorm(30))
# 使用不同形状绘制散点图
ggplot(df, aes(x = x, y = y)) +
geom_point(shape = 21, size = 5, fill='red',colour = "black",stroke = 1) # 使用形状21
二、ggstar包
library(ggstar)
show_starshapes()
使用方法:
df <- data.frame(x = LETTERS[1:8], y = 1:8)
ggplot() +
geom_star(data = df, aes(x = x, y = y, starshape = x, fill = x), size = 5) +
theme_bw()
本文最后更新于
2024-12-31
如有失效,请留言
THE END