Error: Aesthetics must be either length 1 or the same as the data (36): label

My code is typed as following:
formula <- y ~ x-1
lbs <- c('2014',"2015","2016","2017","2018","Whole")
lbs <- paste0('(',lbs,')')
formula <- y ~ x-1
Fig_G_BM <-ggplot(dt1, aes(x=G_ori_BM,y=G_adj_BM))+ facet_wrap(.~Year_Sort,ncol=3,nrow = 2,shrink = TRUE)+#,scales = 'free_y')
geom_hline(yintercept=c(-200,-100,0,100,200,300,400),colour="grey90")+
geom_vline(xintercept=c(-200,-100,0,100,200,300,400),colour="grey90")+
theme_bw()+
theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank())+
stat_binhex(bins=50)+
scale_fill_gradient2(low = "red", mid = "yellow",
high = "blue", midpoint = 95, space = "Lab",
breaks=c(0,100,200),limits=c(0, 200),
na.value ="blue",guide="colourbar",aesthetics = "fill")+
geom_abline(intercept = 0, slope = 1, colour="black", size=.6)+
stat_smooth(method="lm",formula = formula,se=F,colour="black",linetype=2,size=1.5)+
stat_poly_eq(aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~")),
label.x.npc = "right",label.y.npc = "bottom",
formula = formula, parse=TRUE, size=4)+
labs(x="Gs_ori_BM (W/m-2)",y="Gs_adj_BM (W/m-2)")+
annotate("text",label=lbs, x=-180,y=360,family="myFont",size=5,fontface="bold",color="black",hjust=0,vjust=0,angle=0 )+
theme(axis.title.x=element_text(family="myFont",size=15,face="bold",color="black",hjust=0.5,vjust=0.1,angle=0),
axis.title.y=element_text(family="myFont",size=15,face="bold",color="black",hjust=0.5,vjust=2,angle=90),
axis.text.x=element_text(family="myFont",size=10,face="bold",color="black",hjust=1,angle=0),
axis.text.y=element_text(family="myFont",size=10,face="bold",color="black",hjust=1,angle=0),
strip.background = element_blank(),strip.text = element_blank(),
panel.spacing = unit(1.5, "lines"),
aspect.ratio=1)+
coord_cartesian(expand = F)+#coord_fixed(ratio=1)+
scale_x_continuous(expand = c(0,0),breaks = c(-200,-100,0,100,200,300,400),limits = c(-200,400))+
scale_y_continuous(expand = c(0,0),breaks = c(-200,-100,0,100,200,300,400),limits = c(-200,400))
I got the error "Error: Aesthetics must be either length 1 or the same as the data (36): label". Then I set lbs<-1:36, then i got another error message "Error: Aesthetics must be either length 1 or the same as the data (216): label". Then I changed lbs<-1:216, then repeated that, I got the new error messages “Error: Aesthetics must be either length 1 or the same as the data (1296):label” again. I couldn't understand why?

Hi!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.