R IN ACTION SELF-TUTORIAL-76 绘制E

2022-12-18  本文已影响0人  RashidinAbdu

需要作图,所以把代码分享一下!




a1<- read.table("C:/Users/RashidinAbdugheni/Desktop/Re_704/7-1.txt",header=T,na.strings = c("NA"))
a2<- read.table("C:/Users/RashidinAbdugheni/Desktop/Re_704/8-1.txt",header=T,na.strings = c("NA"))
print(a)

library(ggplot2)
library(patchwork)
fig7_1<-ggplot(a1, aes(Energy,Counts)) + 
  geom_line(,cex=0.2,color="black")+theme_bw()+
  scale_x_continuous(breaks=seq(0,20,2),name="ke/V") +
  scale_y_continuous(breaks=seq(0,1000,100),name="Counts/cps")+
  theme(element_blank())+
  theme(axis.title = element_text( color = "black", size = 14, face = "bold"))+
  theme(axis.ticks = element_line(color = "black"))
  
fig7_1

ggsave(fig7_1, file='C:/Users/RashidinAbdugheni/Desktop/Re_704/fig7_1.pdf', 
       width=6, height=4) 


fig8_1<-ggplot(a2, aes(Energy,Counts)) + 
  geom_line(,cex=0.2,color="black")+theme_bw()+
  scale_x_continuous(breaks=seq(0,20,2),name="ke/V") +
  scale_y_continuous(breaks=seq(0,1300,100),name="Counts/cps")+
  theme(element_blank())+
  theme(axis.title = element_text( color = "black", size = 14, face = "bold"))+
  theme(axis.ticks = element_line(color = "black")) #刻度尺的设置
  
fig8_1

ggsave(fig8_1, file='C:/Users/RashidinAbdugheni/Desktop/Re_704/fig8_1.pdf', 
       width=6, height=4) 
#合并两张,左右排放,然后另存输出为PDF格式figall文件!
library("patchwork")
figall<-fig7_1+fig8_1
figall

ggsave(figall, file='C:/Users/RashidinAbdugheni/Desktop/Re_704/figall.pdf', 
       width=14, height=6) 

image.png
上一篇 下一篇

猜你喜欢

热点阅读