################################################################################### # # Plot 2D maps of sample locations - quantitative variables # # Last review: 17/06/2018 # email: ja@fct.unl.pt # ################################################################################### ################################################################################### varcolX <- 1 varcolY <- 2 varlistindex <- 6 circlesize <- c(1,5) titleGRAPH <- "Planta de amostragem de solos" colours <- c("blue", "green", "yellow", "red") ################################################################################### library("ggplot2") library("scales") # # Duplicate gtd -> gtdnew # gtdnew <- data.frame(gtd[,c(varcolX,varcolY,varlistindex)]) names(gtdnew)=names(gtd[,c(varcolX,varcolY,varlistindex)]) # # Graphic # circlerange=circlesize[2]-circlesize[1] ggplot(gtdnew, aes(x = gtdnew[,1], y = gtdnew[,2], fill=gtdnew[,3])) + geom_point(shape = 21, alpha=1.0, size = 1+circlerange*(gtdnew[,3]-min(gtdnew[,3]))/(max(gtdnew[,3])-min(gtdnew[,3])), colour="gray10", show.legend=T) + scale_size(range = circlesize, guide = "none") + scale_fill_gradientn(colours = colours) + ggtitle(titleGRAPH) + labs(x = names(gtdnew)[1], y = names(gtdnew)[2], fill = names(gtdnew)[3]) + coord_fixed() + theme_bw()