Skip to content
Prev 5978 / 7420 Next

Producing images of Plant leaves in R

Hi Eric,

I didn't look for an existing tool (you might try rseek.org) but
here's a quick and dirty leaf sketch tool that might give you an idea
for making your own.

leaf <- function(leafheight, width10, width50, width90, origin = c(0,
0), add = TRUE, main = "Leaf sketches", scaleheight, ...) {

# draws a schematic leaf based on height and three widths
# if add = FALSE, creates a blank plot
# places leaf base at origin point
# takes additional parameters to polygon such as col
# if scaleheight is missing, scales measurements so leafheight == 1

if(missing(scaleheight))
scaleheight <- leafheight

width10 <- (width10 / scaleheight) / 2
width50 <- (width50 / scaleheight) / 2
width90 <- (width90 / scaleheight) / 2
leafheight <- leafheight / scaleheight

maxwidth <- max(c(width10, width50, width90))

if(!add)
plot(c(-maxwidth, maxwidth), c(0, 1), xaxt = "n", yaxt = "n", xlab =
"", ylab = "", type = "n", main = main)

x <- c(0, width10, width50, width90, 0, -width90, -width50, -width10, 0)
y <- c(0, .1, .5, .9, 1, .9, .5, .1, 0) * leafheight
polygon(x, y, ...)

invisible()
}




###

leaf(50, 60, 30, 10, add = FALSE, main = "Leaf sketches")
leaf(20, 5, 8, 2, scaleheight = 50, border = "green", lwd = 3)
leaf(50, 2, 10, 15, scaleheight = 50, border = "red")
On Tue, Jun 11, 2019 at 4:08 PM Eric Doucette <eric.t.doucette at gmail.com> wrote: