Learn R Programming

ursa (version 3.10.4)

compose_legend: Plot colorbars or marginal texts.

Description

compose_legend recognizes color tables and characters among arguments and passes them to suitable functions for plotting on margins outside of panel area.

Usage

compose_legend(...)

Value

NULL

Arguments

...

If first argument is a list, then either ursaColorTable or character objects are detected in this list. ursaColorTable can be extracted from ursaRaster (if presents). Other objects are coerced to character.

If first argument is ursaColorTable or ursaRaster with color tables, then other arguments are interpreted as color tables. If coercion to color table is impossible, the coersion is to character.

legend_colorbar is called for objects of class ursaColorTable. legend_mtext is called for objects of class ursaColorTable. If first argument is a list, then other arguments are passed to respective function calls.

Author

Nikita Platonov platonov@sevin.ru

Details

Named list in the first argument is allowed or named vectors are allowed if first argument is not a list. For legend_colorbar name of object can be used as an argument units.

This function is designed to make plot on moderate level of usage with the followed construction:


compose_open(...)
compose_panel(...)
compose_legend(...)
compose_close(...)

Function compose_panel returns list of color tables of plotted rasters, and followed sequence is available:


ct <- compose_panel(a)
compose_legend(ct) # or, if 'a' has color tables, then 'compose_legend(a)'

See Also

legend_colorbar

legend_mtext

Examples

Run this code
session_grid(NULL)
b <- lapply(as.list(ursa_dummy(2)),colorize)
cd <- compose_design(layout=c(1,2),legend=list(list(1,"left"),list(1,"right")
                                              ,list("top","full"),list("bottom",1)))
for (i in 1:4) {
   compose_open(cd,dev=i==1)
   ct <- compose_panel(b,decor=FALSE)
   if (i==2)
      compose_legend(ct)
   else if (i==3)
      compose_legend(ct[[1]],'Tomorrow'=b[[2]]
                    ,top="This is example of legend composition"
                    ,format(Sys.Date(),"(c) %Y"))
   else if (i==4)
      compose_legend(c(ct,"top","bottom"),units=c("left","right"))
   compose_close()
}

Run the code above in your browser using DataLab