绘制ggplot相位图高级标识
来源:互联网 发布:linux grep命令详解 编辑:程序博客网 时间:2024/06/15 20:33
受师弟询问启发做的ggplot箱线图高级标识
rm(list = ls())
library(ggplot2)
phdfig23 = read.table("PhD_fig23.csv", header=TRUE, sep=",", na.strings="NA", dec=".", strip.white=TRUE)
phdfig23_long = with(phdfig23,
rbind( data.frame( lesion=group, stimulus="CS+", approaches=CSplus, sem=SEMCSplus ),
data.frame( lesion=group, stimulus="CS-", approaches=CSminus, sem=SEMCSminus ) )
)
q = ggplot(data = phdfig23_long, aes(x=lesion, y=approaches, fill=stimulus, width=0.5) ) + # width here determines bar spacing
# ... see http://stats.stackexchange.com/questions/6204/how-to-increase-the-space-between-the-bars-in-a-bar-plot-in-ggplot2
geom_errorbar(aes(ymin=approaches, ymax=approaches+sem, width = 0.2), position=position_dodge(width=0.8)) +
geom_bar(stat="identity", position=position_dodge(width=0.8)) + # WORKAROUND, as above
geom_bar(stat="identity", position=position_dodge(width=0.8), colour="black", legend=FALSE) + # WORKAROUND, as above
scale_fill_manual(values=c("grey80", "white")) +
scale_x_discrete("Group", limits=c("sham", "ACCX")) + # a way to specify the order of factors directly
scale_y_continuous("Number of approaches", expand=c(0,0), limits = c(0, 17), breaks=seq(0, 16, by=2)) +
geom_segment(aes(x=0.8, y=15.3, xend=0.8, yend=16)) + #从这一步开始做线,起始位置为(0.8,15.3)拉伸到(0.8,16)就是横坐标不变,增坐标从15.3拉高到16
geom_segment(aes(x=0.8, y=16, xend=1.2, yend=16)) + #同理起始位置是(0.8,16)拉伸到(1.2,16)纵坐标不变,横坐标从0.8拉伸到1.2
geom_segment(aes(x=1.2, y=6, xend=1.2, yend=16)) + #同理起始位置是(1.2,6)拉伸到(1.2,16)横坐标不变,纵坐标从6拉伸到16
annotate("text", x=1, y=15.5, label="***") + #这里开始填写你需要些的东西,注意横坐标在0.8-1.2范围内,纵坐标在15.3-16之间
theme_bw() + #以下labs为图形各个参数的配置
labs(title = "Autoshaping probe test",
plot.title = element_text(face="bold", size=14),
axis.title.x = element_text(face="bold", size=12),
axis.title.y = element_text(face="bold", size=12, angle=90),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.text.y=element_text(angle=90, hjust=0.5), # rotate the Y axis text anticlockwise 90 degrees, and centre it (0 left, 0.5 centre, 1 right)
legend.title = element_blank(),
legend.position = c(0.85,0.85),
legend.key.size = unit(1.5, "lines"),
legend.key = element_rect() # provides a border to the coloured squares in the legend
)
print(q)
- 绘制ggplot相位图高级标识
- 相位图
- 用ggplot画饼图
- ggplot
- ggplot 多列bar图
- R笔记3:ggplot绘制商务图表…
- 折线图(三)绘制x轴单位值,以及标识物
- unix环境高级编程-1.8-用户标识
- 《UNIX环境高级编程》笔记--系统标识
- 《UNIX环境高级编程》笔记--系统标识
- 中值滤波后的未解缠相位图
- R语言:ggplot做条形图和线图尝试
- C#高级编程:绘制文本
- R语言绘制韦恩图并在图上加线标识
- chmod命令高级篇( SetUID与SetGID标识位)
- UNIX 环境高级编程(七)—— 进程标识
- chmod命令高级篇( SetUID与SetGID标识位)
- 线性相位
- 混合运算与类型转换规律
- 第3章:微服务治理
- JAVA面试题------根据所给格式将字符串中单词倒置
- 作业
- ubuntu下sudo apt-get update出错:E: Could not get lock /var/lib/apt/lists/lock
- 绘制ggplot相位图高级标识
- (HDU
- 七层网络模型与四层网络模型
- Solr 热更新,不重启修改配置文件
- Tomcat文件服务器搭建过程详解
- Date类和Calendar类
- Mac OS X 下安装 TensorFlow
- UVa 105|The Skyline Problem|暴力|线段树
- 二叉树相关操作