Мне нужно поместить легенду под заголовком изображения, но я не знаю, как это легко сделать
par(mfrow=c(2,3),oma=c(0,0,0,0),xpd=NA)
maximo<-max(valuetable[,-ncol(valuetable)],na.rm = T )
c1<-which(data$class==1);cluster1 <- data[c1,]
c2<-which(data$class==2);cluster2 <- data[c2,]
c3<-which(data$class==3);cluster3 <- data[c3,]
c4<-which(data$class==4);cluster4 <- data[c4,]
c5<-which(data$class==5);cluster5 <- data[c5,]
hist(as.matrix(cluster1[,-ncol(cluster1)]),ylab="Frecuencia",xlab="Precipitación (mm)",ylim=c(0,3000), xlim=c(0,maximo),col=Set1T[1],main="");box()
hist(as.matrix(cluster2[,-ncol(cluster2)]),ylab="Frecuencia",xlab="Precipitación (mm)",ylim=c(0,3000), xlim=c(0,maximo),col=Set1T[2],main="");box()
hist(as.matrix(cluster3[,-ncol(cluster3)]),ylab="Frecuencia",xlab="Precipitación (mm)",ylim=c(0,3000), xlim=c(0,maximo),col=Set1T[3],main="");box()
hist(as.matrix(cluster4[,-ncol(cluster4)]),ylab="Frecuencia",xlab="Precipitación (mm)",ylim=c(0,3000), xlim=c(0,maximo),col=Set1T[4],main="");box()
hist(as.matrix(cluster5[,-ncol(cluster5)]),ylab="Frecuencia",xlab="Precipitación (mm)",ylim=c(0,3000), xlim=c(0,maximo),col=Set1T[5],main="");box()
mtext("Histogramas de Precipitación", side = 3, line = -1.5, outer = TRUE)
legend("top",legend=c("Cluster 1", "Cluster 2","Cluster 3","Cluster 4","Cluster 5"),col = 1:5, lty=1,horiz = T,lwd=3, bty = "n", cex = 1.3)