[R] need to plot multiple spatial maps side-by-side in a single window using sf plot function in R
Bert Gunter
bgunter@4567 @end|ng |rom gm@||@com
Sat May 14 20:06:17 CEST 2022
It seems that sp uses the lattice package and spplot() for multiple
plots. These are completely incompatible with base plot's par(mfrow
=...) multiple plotting. I think you need to study how lattice works.
In particular, see ?plot.trellis and ?xyplot for some relevant info.
You might also do better posting this on r-sig-geo,
https://stat.ethz.ch/mailman/listinfo/r-sig-geo , where expertise on
this sort of thing is more likely to reside.
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Sat, May 14, 2022 at 10:02 AM Ranjeet Kumar Jha
<ranjeetjhaiitkgp using gmail.com> wrote:
>
> Hi,
>
> I like to plot all my 5 spatial maps of drought indices in a single window
> using the sf plot function in R. I am able to plot all maps separately but
> unable to plot altogether. All indexes are showing drought indices.
>
> I really appreciate your help!
>
> Here is the code:
>
> #merging using merge function
> merge_drought_indices <- merge(shp_dist, drought_indices)
> view(merge_drought_indices)
> #plot in a single window
> library(sp)
> par(mfrow=c(2,2))
> plot(merge_drought_indices["r_count_lt_p05_harvest_end"],
> pal = colorRampPalette(c("red", "white", "blue","green")),
> main = "End harvest index variation in India during drought year 2000",
> key.pos = 4, axes = TRUE, key.width = lcm(1.3), key.length = 1.0)
>
> plot(merge_drought_indices["r_count_lt_p05_harvest"],
> pal = colorRampPalette(c("red", "white", "blue","green")),
> main = "Harvest variation index in India during drought year 2000",
> key.pos = 4, axes = TRUE, key.width = lcm(1.3), key.length = 1.0)
>
> plot(merge_drought_indices["r_count_lt_p05_main"],
> pal = colorRampPalette(c("red", "white", "blue","green")),
> main = "Main growth stage index variation in India during drought year 2000",
> key.pos = 4, axes = TRUE, key.width = lcm(1.3), key.length = 1.0)
>
> plot(merge_drought_indices["r_count_lt_p05_plant.start"],
> pal = colorRampPalette(c("red", "white", "blue","green")),
> main = "Plant start index variation in India during drought year 2000",
> key.pos = 4, axes = TRUE, key.width = lcm(1.3), key.length = 1.0)
>
> plot(merge_drought_indices["r_count_lt_p05_plant"],
> pal = colorRampPalette(c("red", "white", "blue","green")),
> main = "main plant stage index variation in India during drought year 2000",
> key.pos = 4, axes = TRUE, key.width = lcm(1.3), key.length = 1.0)
>
>
> Regards and Thanks,
>
> Ranjeet
>
>
>
> --
>
>
>
> *"Simple Heart, Humble Attitude and Surrender to Supreme Being make our
> lives beautiful!"*
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list