Skip to content

How would I set the background color of an output SVG? #45

Answered by alshan
Mee42 asked this question in Q&A
Discussion options

You must be logged in to vote

That's right, there is no 'background' in SVG container - it's always transparent.

One way to make it opaque is to manually add a filled rectangle before the rest of the contents:

<rect width="100%" height="100%" fill="white"/>

Such an option in ggsave() would be useful IMO.
Even better would be to have an easy way to set a desirable background in IDEA SVG viewer itself - please vote: https://youtrack.jetbrains.com/issue/IDEA-250345

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Mee42
Comment options

@alshan
Comment options

Answer selected by Mee42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants