R語言用pplot和for回圈畫圖如何分別添加每個圖y軸的范圍,我只會寫批量修改Y軸范圍的程式,但是這里需要單獨確定每個圖Y軸的范圍,代碼如下:
for (i in seq(1,ncol(data1),by=3)) {print(i)
name<-names(data1[i+1])
tiff(filename = paste("trend/",name,".tiff", sep = ""))
x=data1[,i]
y=data1[,i+1]
y2=data1[,i+2]
g<- ggplot(data1)+
geom_point(data = data1,aes_string(x,y),size=2,color="black")+
geom_line(data=https://bbs.csdn.net/topics/data1,aes_string(x,y2),color="black",group=1)+
labs(x="year",y="temperature")+ggtitle(name)+
scale_x_continuous(breaks=c(1950,1955,1960,1965,1970,1975,1980,1985,1990,1995,2000,2005,2010,2015,2020),
labels=c("1950","1955","1960","1965","1970","1975","1980","1985","1990","1995","2000","2005","2010","2015","2020"))+
theme_set(theme_bw())+
theme(axis.ticks.length = unit(-0.05,'cm'),axis.text = element_text(margin = unit(c(0.5,0.5,0.5,0.5),'cm')))+
theme(title= element_text(size=15, family="TNR", color="black", face= "bold", vjust=0.5,hjust = 0.5))+
theme(plot.title = element_text(hjust = 0.5))+
theme(axis.title= element_text(size=15, family="TNR", color="black", face= "bold", vjust=0.5, hjust=0.5))+
theme(axis.text = element_text(size=10, family="TNR", color="black", face= "bold", vjust=0.5, hjust=0.5))
print(g)
dev.off()
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/144701.html
標籤:其他技術專區
上一篇:Silverlight有類似wpf中的DynamicResource特性嗎
下一篇:[Tensorflow問題]kitti深度圖轉tfrecords,InvalidArgumentError: image must be 3-dimension
