Closed sckott closed 4 years ago
oh, it's been a while since I looked at this code!
I vaguely remember the usr
offset thing being necessary at the time, I thought it was there so that placing the silhouettes didn't get scaled weirdly when being plotted by rasterImage
(since you need to specify the corner coordinates). Does the user have a reprex?
Thanks. They just sent one:
library(rphylopic)
add_phylopic_base2 <- function (img, x = NULL, y = NULL, ysize = NULL, alpha = 0.2,
color = NULL)
{
img <- rphylopic:::recolor_phylopic(img, alpha, color)
dims <- dim(img)[1:2]
AR <- dims[1]/dims[2]
# graphics::par(usr = c(0, 1, 0, 1))
graphics::rasterImage(img, x - (ysize/2), y - (AR * ysize/2),
x + (ysize/2), y + (AR * ysize/2), interpolate = TRUE)
}
## My sampled species
z <- image_data("7f2cbb42-12b1-4481-8ac0-705eb7363c74", size = "128")[[1]]
## Coordinates
set.seed(999)
X <- runif(10, 0, 2)
Y <- runif(10, 0, 2)
par(mfrow=c(2,1), bty="n", xlim=c(0,2))
## Plot using the original formula
plot(X, Y, pch=3, col="red", xlim=c(0,2), ylim=c(0,2), main="Original function")
add_phylopic_base(z, x = X, y = Y, ysize = 0.4)
## Plot using the modifyed funtion. Trout appear on the top of the observations
plot(X, Y, pch=3, col="red", xlim=c(0,2), ylim=c(0,2), main="Modified function")
add_phylopic_base2(z, x = X, y = Y, ysize = 0.4)
user asks if the line
graphics::par(usr = c(0, 1, 0, 1))
https://github.com/sckott/rphylopic/blob/master/R/add_phylopic_base.r#L46 should be changed/removedsays
any ideas @dill ?