JunoLab / Weave.jl

Scientific reports/literate programming for Julia
http://weavejl.mpastell.com
MIT License
831 stars 95 forks source link

Compose with Gadfly doesn't support pdf figure output. #266

Open zaphar opened 4 years ago

zaphar commented 4 years ago

Details are in https://github.com/GiovineItalia/Compose.jl/issues/372 It's possible that this just needs to be noted in the documentation until Compose supports show methods for pdf output. Or Weave could shim in a show method until then.

Setting the chunk option fig_ext=".png" or another supported format appears to workaround it.

Mattriks commented 4 years ago

Note this issue only occurs with hstack'd or vstack'd plots. Same with any Compose.Context. The workaround I found was to explicitly include a draw call:

draw(PDF(), hstack(plot1, plot2));
Mattriks commented 4 years ago

Looking at Weave.jl src now. The issue is that hstack'd and vstack'd plots are no longer objects of type Gadfly.Plot, as they are converted to objects of type Compose.Context.

Weave's gadfly.jl file defines display methods only for Gadfly.Plot. But Gadfly's display methods are defined for Union{Gadfly.Plot, Compose.Context}, so I think this is what needs to be done in Weave.jl. This would also enable Compose graphics in Weave.

zaphar commented 4 years ago

Yeah, I can confirm that this works in a simple test as well.