Overlay a ggplot with an image and apply CSS effects

Perhaps nonsensically, I'd like to overlay a ggplot with an image, and then apply CSS effects to that image. I can think of two possible approaches:

  1. Create an htmlwidget that saves the plot to a PNG, overlay the PNG with JS, and apply a CSS class to the image.
  2. Maybe the magick package? I'm not an expert in its inner workings.

Is either option feasible? If not, is there a third way?


Could you elaborate on what the purpose of the end result would be and give an example or two. Also, would this be implemented in Shiny?

Please provide a Reprex if possible

Good luck!

1 Like

Nothing would give me greater joy than producing a reprex, but I do not know how to get there. I know one can render PNG and JPG files within the htmlwidgets framework, and then I suppose hypothetically style the image with included CSS, but is that is the best approach? The magick package might be a better alternative, but I do not have much experience with that package.

My plan was to add various effects to an image of a plot--shimmers, sparkles, glitters, shadows, distortions, etc. Fingers crossed that it would scale to Shiny.


Unfortunately I also don't have experience with the Magick package...
Af far as I understand, Shiny does create an image from a normal (non interactive) plot or ggplot. So you should be able to get its CSS tags and then modify it. I still don't fully understand the intent is here, so would it be possible to show what you want with just a regular png image and then later we can worry about the plot?


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