g <- symbolmap(inputs=letters[1:10], pch=11:20)
g1 <- symbolmap(range=c(0,100), size=function(x) x/50)
## squares and circles with area proportional to |x|
## For 'squares', size is side length; size = sqrt(area)
## For 'circles', size is diameter; size = sqrt(area * 4/pi)
g2 <- symbolmap(shape=function(x) ifelse(x > 0, "circles", "squares"),
size=function(x) sqrt(ifelse(x > 0,
abs(x)*4/pi,
abs(x))),
bg = function(x) ifelse(abs(x) < 1, "red", "black"))
colmap <- colourmap(topo.colors(20), range=c(0,10))
g3 <- symbolmap(pch=21, bg=colmap, range=c(0,10))
plot(g3)
## logarithmic symbol map
gm <- symbolmap(range=c(1,1000), pch=21, transform=log10,
size=function(x) { x + 1 })
## input value x is plotted as a circle of diameter = log10(x) + 1.
gm(100)
plot(gm, nsymbols=4)
## note logarithmic scale of legend, because compress=transform by default.
## logarithmic display scale only
gl <- symbolmap(range=c(1,1000), pch=21, compress=log10)
gl(10)
plot(gl, nsymbols=4)
gu <- symbolmap(range=c(1,1000), pch=21)
gu(10)
plot(gu, nsymbols=4)
## log transformation 'compress' does not affect symbol map itself
Run the code above in your browser using DataLab