Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #26 #28

Merged
merged 3 commits into from
Jun 2, 2020
Merged

fix #26 #28

merged 3 commits into from
Jun 2, 2020

Conversation

dill
Copy link
Contributor

@dill dill commented Jun 2, 2020

Description

Better handling of image scale, avoids use of par(usr... bits.

Related Issue

fix #26

Example

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))

## 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-06-02 at 18 06 15

"original function" above is now what is in rphylopic :)

David Lawrence Miller added 2 commits June 2, 2020 18:03
examples in add_phylopic_base.

Fixes first example in add_phylopic_base

fixes palaeoverse#27
Copy link
Collaborator

@sckott sckott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work. just 1 comment

#' plot(posx, posy, type="n", main="A cat herd, on top of a cat",
#' xlim=c(0,1), ylim=c(0,1))
#' # get a higher-resolution cat
#' cat_hires <- image_data("23cd6aa4-9587-4a2e-8e26-de42885004c9", size = 128)[[1]]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like this isn't any higher res? 128 and 128. maybe use 512?

@dill
Copy link
Contributor Author

dill commented Jun 2, 2020 via email

@sckott sckott added this to the v0.3 milestone Jun 2, 2020
@sckott
Copy link
Collaborator

sckott commented Jun 2, 2020

👌

@sckott
Copy link
Collaborator

sckott commented Jun 2, 2020

purrfct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add_phylopic_base issue
2 participants