我可以找到解决以下问题的方法.我会非常感谢一些帮助!
以下代码使用facet生成条形图.但是,由于"额外空间"ggplot2在某些组中使得条形更宽,即使我指定宽度为0.1或类似.我发现这非常烦人,因为它使它看起来非常不专业.我希望所有的条看起来都一样(填充除外).我希望有人能告诉我如何解决这个问题.
其次,如何重新排序构面窗口中的不同类,以便顺序始终为C1,C2 ... C5,M,F,全部适用.我尝试了它来排序因子的级别,但由于并非所有的类都出现在每个图形部分中它都不起作用,或者至少我认为这就是原因.
第三,如何减少酒吧之间的空间?这样整个图形就更加压缩了.即使我将图像缩小以进行导出,R也会将条形缩小,但条形之间的间距仍然很大.
我希望得到任何答案的反馈!
我的数据:http: //pastebin.com/embed_iframe.php?i = kNVnmcR1
我的代码:
library(dplyr)
library(gdata)
library(ggplot2)
library(directlabels)
library(scales)
all<-read.xls('all_auto_visual_c.xls')
all$station<-as.factor(all$station)
#all$group.new<-factor(all$group, levels=c('C. hyperboreus','C. glacialis','Special Calanus','M. longa','Pseudocalanus sp.','Copepoda'))
allp <- ggplot(data = all, aes(x=shortname2, y=perc_correct, group=group,fill=sample_size)) +
geom_bar(aes(fill=sample_size),stat="identity", position="dodge", width=0.1, colour="NA") + scale_fill_gradient("Sample size (n)",low="lightblue",high="navyblue")+
facet_wrap(group~station,ncol=2,scales="free_x")+
xlab("Species and stages") + ylab("Automatic identification and visual validation concur (%)") +
ggtitle("Visual validation of predictions") +
theme_bw() +
theme(plot.title = element_text(lineheight=.8, face="bold", size=20,vjust=1), axis.text.x = element_text(colour="grey20",size=12,angle=0,hjust=.5,vjust=.5,face="bold"), axis.text.y = element_text(colour="grey20",size=12,angle=0,hjust=1,vjust=0,face="bold"), axis.title.x = element_text(colour="grey20",size=15,angle=0,hjust=.5,vjust=0,face="bold"), axis.title.y …Run Code Online (Sandbox Code Playgroud)