# Suggestions to make Weave work with PyPlot?

**URL:** <https://discourse.julialang.org/t/suggestions-to-make-weave-work-with-pyplot/22314>\
**Category:** General Usage\
**Created:** [March 25, 2019, 5:26pm UTC](https://discourse.julialang.org/t/suggestions-to-make-weave-work-with-pyplot/22314 "2019-03-25T17:26:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)\
**Post date:** [March 25, 2019, 5:26pm UTC](https://discourse.julialang.org/t/suggestions-to-make-weave-work-with-pyplot/22314/1 "2019-03-25T17:26:03Z")

</div>

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:

```julia
clf()
# create figure
gcf()

```

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:

```julia
Weave.push_preexecute_hook() do chunk
    clf()
    return chunk
end

```

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.

---

<div class="post-metadata">

**Author:** ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)\
**Post date:** [March 25, 2019, 10:04pm UTC](https://discourse.julialang.org/t/suggestions-to-make-weave-work-with-pyplot/22314/2 "2019-03-25T22:04:50Z")

</div>

I was able to get something to work on the off chance anyone is interested: [Native PyPlot support · Issue #199 · JunoLab/Weave.jl · GitHub](https://github.com/mpastell/Weave.jl/issues/199)
