将数据整理到excel
image.png
在excel将数据选中复制,然后运行代码
df<-read.table("clipboard",header=T)
library(ggplot2)
ggplot(df,aes(x,y))+
geom_col(width = 0.5,aes(fill=x))+
geom_segment(aes(x=1,xend=1,y=10,yend=12))+
geom_segment(aes(x=1,xend=2,y=12,yend=12))+
geom_segment(aes(x=2,xend=2,y=5,yend=12))+
geom_text(aes(x=1.5,y=12.5),label="*")+
theme_bw()+labs(x="",y="")+
theme(legend.position = "none")
image.png
第一次使用R语言的话需要安装ggplot2
使用到的命令install.packages("ggplot2")
添加星号的位置在label
参数后,对应着可以改成两个或者三个星号
线段是使用geom_segment()
函数添加,可以根据自己的数据来修改。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有