Jump to content
You must now use your email address to sign in [click for more info] ×

GGplot transparency svg appears black


Recommended Posts

I am using the popular ggplot2 package for R to make my scientific plots.

The transparency doesn't seem to work at all in affinity designer (1.10.5) with a very basic plot. All background appears black.

image.png.c4d6d91607b4980d9fcd707499ad111c.png

Browsers and Inkscape open it just fine.

The R code is really basic:

library(ggplot2)
theme_update(
    panel.background = element_rect(fill = "transparent"), # bg of the panel
    plot.background = element_rect(fill = "transparent", color = NA),
    legend.background = element_rect(fill = "transparent"), # get rid of legend bg
    legend.box.background = element_rect(fill = "transparent", colour = NA), # get rid of legend panel bg
    legend.key = element_rect(fill = "transparent", colour = NA)
)

ggplot(cars, aes(speed, dist)) +
    geom_point()

ggsave("test.svg")
ggsave("test.png")

 

I am attaching the test.svg file.

Your help would be much appreciated.

Best,

Jonas

test.svg

Link to comment
Share on other sites

  • Staff

Hi jonasfoe, welcome to the forums!

I can see that there are a few extra (maybe unnecessary?)  layers in the output SVG but we'd need to know what it should look like to offer any advice on how to resolve it.

removing the solid layers reveals this:

 

image.png

Link to comment
Share on other sites

The plot is meant to look like the png attached here. In any other software that I can open the svg with, I get this result.

Only with Affinity Designer do I get the solid layer. Removing the solid layer removes important parts of the figure, as you demonstated (the axes).

 

Thanks for the swift feedback.

test.png

Link to comment
Share on other sites

There a quite a few things in SVGs that the Affinity applications can’t handle.

Out of the (probably many) possible options, one might be to check the ggplot2 export options to see if you can export in the simplest way possible – e.g. no CSS/HTML code, no clip-paths, etc.

Other than that you may have to do various manual changes to the SVG before using it which could affect the overall accuracy of your plot and that could cause further problems ‘down the road’.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.