Giter VIP home page Giter VIP logo

Comments (2)

dill avatar dill commented on June 8, 2024

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?

from rphylopic.

sckott avatar sckott commented on June 8, 2024

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) 

Screen Shot 2020-05-27 at 8 31 05 AM

from rphylopic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.