Но я уже решил это.Проблема состояла в том, что r изменил мою матрицу на вектор для всех однорядных данных.
Вот код, как я ее решил:
color <- brewer.pal(6,"Spectral")
overlap <- read_excel("overlap.xlsx")
par(mar=c(3,3,1,1),mgp=c(2,0.9,0),xaxs="i", yaxs="i")
overlap.dat <- overlap[overlap$`Countries and areas`=="Pakistan",]
overlap.dat <-as.data.frame(t(overlap.dat))
overlap.dat <- as.matrix(overlap.dat, drop=FALSE)
overlap.dat <- as.matrix(overlap.dat[-c(1:8,14),], drop=FALSE)
colnames(overlap.dat)= overlap[overlap$`Countries and areas`=="Pakistan",]$Year
barplot(overlap.dat, main = "Pakistan", col =color, ylim=c(0,100), xlim=c(0,8),cex.names=0.8, names.arg = colnames(overlap.dat),
legend=TRUE, args.legend = list(x="topright",y=100, cex=0.8,bty="n"), las=2 )