Description Usage Arguments Value See Also Examples
Spring has sprung. Trees look dead if they don't have leaves, so enfoliate them.
1 |
x |
A |
n |
The number of objects to stick to branches. |
min.depth |
The tier of branches below which things will not be stuck to
branches. Default is |
max.depth |
The tier of branches above which things will not be stuck to
branches. If not provided, |
xy |
Should the coordinates of the random leaves be returned? |
plot |
Should the leaves be added to the existing plot? |
... |
Additional arguments passed to |
If xy
is TRUE
, a data.frame
containing the branch
addresses (branches
), positions (pos
), and coordinates of
leaves. Additionally, if plot
is TRUE
, randomly located points
will be added to the current plot with the desired pch
,
colour, size etc. (e.g. call foliate
after a plant
has been
plotted).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # Make a seed
s <- seed(50, 10, min.branch.length=0, max.branch.length=5,
min.trunk.height=5, max.trunk.height=8)
# Germinate it
g <- germinate(s, trunk.width=15, col='peachpuff4')
# Foliate it
leafygreens <- colorRampPalette(paste0('darkolivegreen', c('', 1:4)))(100)
foliate(g, 2000, 4, pch=24:25, col=NA, cex=1.2, bg=paste0(leafygreens, '50'))
# Or add some cherry blossoms
plot(g, trunk.width=15, col='burlywood4')
floralpinks <- colorRampPalette(c('mistyrose', 'hotpink'))(30)
foliate(g, 3000, 4, pch=24:25, cex=1.5, bg=paste0(floralpinks, '20'), col=NA)
# Plant a fandom forest
png(f <- tempfile(fileext='.png'), 700, 600, type='cairo')
leafygreens <- colorRampPalette(paste0('darkolivegreen', c('', 1:4)))(100)
par(mfrow=c(5, 5), mar=rep(0, 4), oma=c(0, 0, 6, 0))
replicate(25, {
s <- seed(50, 10, min.branch.length=0, max.branch.length=5,
min.trunk.height=2, max.trunk.height=5)
g <- germinate(s, angle=20, trunk.width=5, col='peachpuff4')
foliate(g, 1000, pch=24:25, col=NA, cex=1.2, bg=paste0(leafygreens, '20'))
})
mtext('A random forest', 3, 3, TRUE, font=2, cex=2)
dev.off()
file.show(f)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.