Png transparent background

Hello! I am trying to transpose an image onto a donut chart. The image (world.png) originally has a transparent background but is showing up with a white background. Does anyone know how to troubleshoot the issue?

setwd("~/Desktop")
library("patchwork")
library(png)
library(grid)

img <- readPNG('~/Desktop/world.png')
g <- rasterGrob(img, interpolate=TRUE)

p_image <- plotsun + # plotsun was created using ggplot
inset_element(p = g,
left = -0.005,
bottom = 0.3,
right = 0.9,
top = 0.7)
p_image

plotsun + # plotsun was created using ggplot
inset_element(p = g,
left = -0.005,
bottom = 0.3,
right = 0.9,
top = 0.7)+ theme(rect  = element_rect(fill="transparent"))
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.