美文网首页
Fig3-E 2020-12-07

Fig3-E 2020-12-07

作者: RashidinAbdu | 来源:发表于2022-04-16 12:21 被阅读0次

1.用Excel准备数据并存为CSV格式,数据格式与内容为:


image.png

读取数据:

e<-read.csv(file.choose())
e
image.png

2.开始作图:

library(ggplot2)
ep<-ggplot(e,aes(x=Pairwise.connections,y=Percentage.change.from.monoculture,fill=pos))+geom_bar(stat="identity")
ep
image.png

然后对图例的文字,位置,坐标轴等进行修改:

ep<-ep+theme(legend.position="bottom")#图例调整到最低部分
ep
image.png

去除legend title:

ep<-ep+theme(legend.title = element_blank())
ep
image.png

对坐标轴标签进行角度变化:

ep<-ep+theme(axis.text.x = element_text(angle = 90, hjust = 1))
ep

得到:


image.png

调整横坐标名字的格式:

ep<-ep + theme(axis.title.x = element_text(size = 15, color = "black", face = "bold", vjust = 0.5, hjust = 0.5))
ep

得到:


image.png

调整纵坐标的名称格式:

ep<-ep + theme(axis.title.y = element_text(size = 15, color = "black", face = "bold", vjust = 0.5, hjust = 0.5))
ep

得到:


image.png

调整横坐标标签的间隔:

ep<-ep + scale_x_continuous(breaks=seq(0, 14, 1))
ep

得到


image.png

给纵轴标签间隔进行调整:

ep<-ep + scale_y_continuous(breaks=seq(-40, 150,20 ))
ep

得到:


image.png

删除垂直网格线:

ep<-ep + theme(panel.grid.major.x = element_blank() ,panel.grid.minor.x = element_blank())
ep

得到:


image.png

添加图片名称:

ep<-ep + labs(title="Synergistic versus non-synergistic
interactions")
ep

总的代码:

library(ggplot2)#加载包
 e<-read.csv(file.choose())#读取数据
head(e)
#作图
ep<-ggplot(e,aes(x=Pairwise.connections,y=Percentage.change.from.monoculture,fill=pos))+geom_bar(stat="identity")
ep<-ep+theme(legend.position="bottom")#图例调整到最低部分
ep<-ep+theme(legend.title = element_blank())
ep<-ep+theme(axis.text.x = element_text(angle = 90, hjust = 1))
ep<-ep + theme(axis.title.x = element_text(size = 15, color = "black", face = "bold", vjust = 0.5, hjust = 0.5))
ep<-ep + theme(axis.title.y = element_text(size = 15, color = "black", face = "bold", vjust = 0.5, hjust = 0.5))
ep<-ep + scale_y_continuous(breaks=seq(-100, 150,50 ))
ep<-ep + scale_x_continuous(breaks=seq(0, 14, 1))
ep<-ep + labs(title="Synergistic versus non-synergistic interactions")
ep<-ep + theme(panel.grid.major.x = element_blank() ,panel.grid.minor.x = element_blank())
ep<-ep+theme(panel.grid.major.y = element_line(colour = "black")  ,panel.grid.minor.y = element_blank())
ep
image.png

相关文章

  • Fig3-E 2020-12-07

    1.用Excel准备数据并存为CSV格式,数据格式与内容为: 读取数据: 2.开始作图: 然后对图例的文字,位置,...

  • 周一 2020-12-07 23:20 - 7:14 阴 10h

    2020-12-07 总结的一天,看视频看多了周一 2020-12-07 23:20 - 7:14 阴 10h16...

  • 蜘蛛花复打圈100sc3007

    原创 李大叔 清江风情 2020-12-07 图谱编号:ESB_TP_100_sc3007 直径:39.0~40....

  • 失恋30天

    2020-12-07~2021-1-07,我们已经分手整整30天。 对于题目是叫“失恋30天”,还是叫“分手30天...

  • 怎样批评孩子

    中原焦点团队 成长分享882天 2020-12-07 我们强调,教育孩子要和善而坚定。孩子有不当行为时,既不纵容也...

  • 2020-12-07自我观察记录

    【2020-12-07日精进 第203天/1825】表现:8分 1.早起,完成年度目标新人版和进阶版的对比感悟。...

  • 三句诗

    三句诗 文/自然随心 繁华世间,真爱有三。 时光,残字与卿。 残字寂寥,惟愿卿与时光不老! 2020-12-07夜...

  • 感动到自己泪流满面

    【八小时以外】2020-12-07星期一 今日大雪,天气格外的冷。 早晨送我过孩子,收拾收拾准备去班去,拿起手机...

  • 事件日志(2020.12.7)

    时间:2020-12-07 一、事件&时间 1.邀请一位战友加入践行群(40分钟) 2.帮助邻居查违章(20分钟)...

  • 《你的事可以是我的事,生病灾难根本不是事》

    你的事可以是我的事,生病灾难根本不是事 中毉大夫 2020-12-07 你现在,不管你当下什么情况,都不是个...

网友评论

      本文标题:Fig3-E 2020-12-07

      本文链接:https://www.haomeiwen.com/subject/gkatgktx.html