Suggestions to make Weave work with PyPlot?

I’m trying to make Weave work with PyPlot natively. It already works with the PyPlot backend in Plots.jl, but I’ve got some somewhat tricky plotting code that was easier to do natively than via the Plots.jl interface (plus the Plots.jl custom theme-ing kind of screws things up, and I don’t know if that can be turned off). Weave also already works with PyPlot if you make your chunks look like:

# create figure

but having to manually do the clf()/gcf() screws up some of the readability and is kind of annoying.

I’ve found that I can automatically insert the clf() by doing:

Weave.push_preexecute_hook() do chunk
    return chunk

but I can’t find any way to automatically display the figure at the end too, so you’ll still need the gcf(). Does anyone have anything suggestions for a quick hack to make this work?

Alternatively, I wouldn’t be against trying my hand at making a PR to make this work properly if anyone had some guidance to offer on what exactly it might look like. I’m not an expert on the Julia display backend but willing to learn.

1 Like

I was able to get something to work on the off chance anyone is interested: