I've uploaded my data onto github here:
As you can see, the scales are all the same though they have different values. How can I change it so that 4.0 on one graph is not the same as 1.5 on another?
CodePudding user response:
You can try setting the breaks manually and the type of the rasters as continuous.
library(terra)
plot(vm,
main = titles,
type = "continuous",
breaks = seq(0,4,0.5))
CodePudding user response:
There really ought to be a simple way to specify that you want that, but for now, a quick solution is
rr <- range(minmax(vm))
plot(vm, range=rr, main=month.name)
A more elaborate solution is
m <- cbind(matrix(1:12, ncol=4, byrow=TRUE), 13)
layout(m, c(1,1,1,1,.3))
for (i in 1:12) {
plot(vm[[i]], legend=i==8, range=rr, mar=c(1,1,1,1), plg=list(cex=1.2))
text(20,-17,month.abb[i])
}
And more:
m <- cbind(matrix(1:12, ncol=4, byrow=TRUE), 13)
layout(m, c(1, 1, 1, 1, .5))
par(mgp = c(2, .25, 0))
for (i in 1:12) {
plot(vm[[i]], legend=i==8, range=rr, mar=c(1.2,1.2,.2,0), plg=list(cex=1.2), axes=FALSE)
if (i %in% c(1,5,9)) axis(2, las=1, cex.axis=0.7)
if (i > 8) axis(1, cex.axis=0.7)
box()
text(19,-17,month.abb[i])
}
Removing whitespace (while keeping outside axes), and using the log to get more contrast
lvm <- log(vm)
lrr <- range(minmax(lvm))
m <- matrix(1:12, ncol=4, byrow=TRUE)
m <- rbind(m, 14)
m <- cbind(14, m, 13)
layout(m, c(0.2, 1, 1, 1, 1, .5), c(1,1,1,0.1))
par(mgp = c(2, .25, 0))
for (i in 1:12) {
plot(lvm[[i]], legend=i==8, range=lrr, mar=c(0,0,0,0), plg=list(cex=1.2), axes=FALSE)
if (i %in% c(1,5,9)) axis(2, las=1, cex.axis=0.7)
if (i > 8) axis(1, cex.axis=0.7)
box()
text(19,-17,month.abb[i])
}