Closed jgabry closed 3 years ago
I don't think this is in scope for vdiffr. The approach seems brittle because the graphics engine might take two plots that look exactly the same but draw them in different ways.
@jgabry did you come up with an alternate solution for this?
A possible way to achieve this is by using the same title argument to expect_doppelganger
fig1<- plot_function1()
vdiffr::expect_doppelganger("plot", fig1)
fig2<- plot_function2()
vdiffr::expect_doppelganger("plot", fig2)
This seems to have the desired behaviour when I run the test. It passes if fig1 and fig2 are the same, and fails if they are different.
This is a follow up to https://github.com/r-lib/waldo/issues/56, which made more sense to ask here than in the waldo repo.
Currently
vdiffr::expect_doppelganger()
accepts a single ggplot object as input and compares to an SVG, but is there a way (or would you consider adding a way) to use vdiffr to test that two ggplot objects correspond to the same looking plot? I guess that would require either comparing them both to the same saved SVG or comparing separate SVG files created for each plot to each other.Here's one example of a use case: in the bayesplot package we want to test that two different plotting functions create the same ggplot in the special case where the input matrix has 1 row:
Is there a recommended way of using vdiffr to compare
plot1
toplot2
or, if not, would you consider supporting this?Thank you!