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:
Hello, does anyone know of a package(s) or methods to reproduce the shapes
of plant leaves in R? I have a large dataset (over 7500) of individual
plant leaves for which I have the following measurements: leaf length, leaf
width, leaf width at 1/10 of the overall length below the apex, and leaf
width at 1/10 of the overall length above the base. I am looking for a way
to code to get a visual representation of these lengths. They do not have
to actually be the same as the "real" measurements as long as the ratio of
measurements is correct. Thanks for any advice you can provide,
Eric
[[alternative HTML version deleted]]
_______________________________________________ R-sig-ecology mailing list R-sig-ecology at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Sarah Goslee (she/her) http://www.numberwright.com