##this is the example of my research,NDVI is the undependent variable while Biomass is the dependent variable triandata<-read.table("unave_biomass$vis_622.csv",head=T,sep=",")## import your data into R library(ggplot2) ##loading the package y<-log(Biomass) x<-log(NDVI) ##suppose you use the linear model modelNDVI_3<-lm(y~x,data=traindata) ##set the range of fitting line xmin<-min(log(traindata$NDVI)) xmax<-max(log(traindata$NDVI)) NDVIpredicted<-data.frame(x=seq(xmin,xmax,length.out = 100)) ##get the fitted value between the range of fitting line NDVIpredicted$Biomass<-predict(modelNDVI_3,NDVIpredicted) NDVIpre<-data.frame(NDVI=NDVIpredicted[,1],Biomass=NDVIpredicted[,2]) #using the ggplot2 to draw the scatter plot p<-ggplot(traindata,aes(x=NDVI,y=Biomass))+geom_point(size=3)+scale_fill_brewer(palette = "Pastel2")+theme_bw()+guides(shape=guide_legend(title=NULL)) q<-p+guides(fill=FALSE)+theme(legend.position=c(0.2,0.8)) u<-q+scale_y_continuous(limits=c(0,1),breaks = c(0,0.2,0.4,0.6,0.8,1.0))+ labs(y=expression(paste("Biomass",(kg/m^2))))+ #labs(y=expression(paste("Aboveground biomass",(g/m^2))))+ # ylab("Estimated Biomass (g/m^2)")+xlab("Measured Biomass (gm^2)")+ scale_x_continuous(limits=c(0,0.8),breaks = c(0,0.2,0.4,0.6,0.8)) r<-u+theme(axis.title.x=element_text(size = 22),axis.title.y=element_text(size = 22)) s<-r+theme(axis.text.x=element_text(size=rel(2)),axis.text.y=element_text(size=rel(2))) #added the fitting line according to the dataframe of "NDVIpre" t<-s+geom_line(data=NDVIpre,size=1)+annotate("text",x=0.40,y=0.99,label="(a)",size=9) t