I would like to do a LISA cluster.
Now I would like to change the order of the LISA Cluster in R
quadrant <- vector(mode="numeric",length=nrow(local))
# centers the variable of interest around its mean
m.qualification <- OA.Census$Qualification - mean(OA.Census$Qualification)
# centers the local Moran's around the mean
m.local <- local[,1] - mean(local[,1])
# significance threshold
signif <- 0.1
# builds a data quadrant
quadrant[m.qualification >0 & m.local>0] <- 4
quadrant[m.qualification <0 & m.local<0] <- 1
quadrant[m.qualification <0 & m.local>0] <- 2
quadrant[m.qualification >0 & m.local<0] <- 3
quadrant[local[,5]>signif] <- 0
# plot in r
brks <- c(0,1,2,3,4)
colors <- c("white","blue",rgb(0,0,1,alpha=0.4),rgb(1,0,0,alpha=0.4),"red")
plot(OA.Census,border="lightgray",col=colors[findInterval(quadrant,brks,all.inside=FALSE)])
box()
legend("bottomleft", legend = c("insignificant","low-low","low-high","high-low","high-high"),
fill=colors,bty="n")
But I don't know how can I do that
I want high high at top and insignificant at last
since I can't share any data that was the only solution I found
CodePudding user response:
Just rev
erse the colors
and legend
vectors:
colors <- rev(c("white","blue",rgb(0,0,1,alpha=0.4),rgb(1,0,0,alpha=0.4),"red"))
legend("bottomleft", legend = rev(c("insignificant","low-low","low-high","high-low","high-high")),
fill=colors,bty="n")
CodePudding user response:
colors <-(c("white","blue",rgb(0,0,1,alpha=0.4),rgb(1,0,0,alpha=0.4),"red"))
legend("bottomleft", legend = rev(c("insignificant","low-low","low-high","high-low","high-high")),
fill=rev(colors),bty="n")
This is the right code