7

I'm trying to use a non squared image in a {ggimage} layer but I can't seem to make the ratio fit the orignal image ratio. Documentation points to the asp argument but this doesn't seem to work.

Here's an obviously non square image : https://ps.w.org/insert-headers-and-footers/assets/banner-772x250.png

Here is the result from {ggimage}:

library(ggimage)
library(ggplot2)
d <- data.frame(
  x = 1,
  y = 1,
  image = "https://ps.w.org/insert-headers-and-footers/assets/banner-772x250.png"
)
ggplot(d, aes(x, y)) + 
  geom_image(aes(image=image), size = 1)

ggplot(d, aes(x, y)) + 
  geom_image(aes(image=image), size = 1, asp = 0.1)

ggplot(d, aes(x, y)) + 
  geom_image(aes(image=image), size = 1, asp = 0.5)

ggplot(d, aes(x, y)) + 
  geom_image(aes(image=image), size = 1, asp = 0.9)

enter image description here

enter image description here

enter image description here

enter image description here

How can I make the image keep the original width/height ratio?

Colin FAY
  • 4,849
  • 1
  • 12
  • 29

0 Answers0