Repository navigation
Set file background from plot theme - #4164
Conversation
|
You could write the png to a temp file, read it back in, plot as a |
|
I couldn't get the |
|
What was the problem with the |
clauswilke
left a comment
There was a problem hiding this comment.
Thinking some more about this, I think this is a reasonable approach.
|
Thanks @clauswilke, and you feel ok about adding xml2 to Suggests? |
|
I realized that writing an image and reading it back in to plot would also require an additional dependency (e.g. png), so it's a wash. And in any case just writing to and reading from svg (rather than writing a png, reading it in, plotting to svg, and then comparing that svg to a reference) is much more efficient. And also, vdiffr imports xml2, so we have this dependency already, implicitly. |
Closes #4057. @clauswilke I took your proposed approach and calculated the theme element to get the background color. I imagine people will still typically want to edit their theme to remove the plot border.
I'm opening this as a draft because I think it needs a test but I'm not sure how best to write one. Is there a way to have vdiffr compare two files rather than comparing a plot object against a file? I imagine there is and that vdiffr is doing this under the hood normally, but I tinkered with it a bit and couldn't figure it out.