JuliaTeX / PGFPlots.jl

This library uses the LaTeX package pgfplots to produce plots.
Other
187 stars 36 forks source link

PGFPlots.Image cleanup before display when using Interact #114

Open kjulian3 opened 5 years ago

kjulian3 commented 5 years ago

On a Windows machine I’ve installed a fresh Jupyter with Julia 1.1 along with the most recent versions of Interact (v0.10.2) and PGFPlots (v3.0.3). I’m having trouble using the @manipulate macro to manipulate a PGFPlots.Image. The PNG file that gets created seems to be deleted before being shown, resulting in the following error:

! Package luatex.def Error: File `tmp_10000000000001.png' not found: using draft 

setting. See the luatex.def package documentation for explanation. 

Type H <return> for immediate help. ... l.14 \end{axis}

If I plot without @manipulate, everything works just fine. Running @manipulate around other functions (such as PGFPlots.plot) also works just fine. The problem seems to be specifically using @manipulate around a PGFPlots.Image function. Here is a minimal working example:

using Interact
using PGFPlots

function testPlot()
    @manipulate for i = [1, 2, 3]
        f = (x,y)->x*exp(-x^2-y^2)
        g=PGFPlots.Image(f, (-i,i), (-i,i), colormap = ColorMaps.GrayMap(invert = true))
    end
end
testPlot()
kjulian3 commented 5 years ago

It seems that when using PGFPlots.Image with Interact, Base.show() gets called twice (Can be seen by adding a print statement to Base.show and setting cleanup(p::Image) = nothing on line 742). Since Base.show deletes the png file during the first call, the second call gives an error that the file is missing. If PGFPlots.Image is called without Interact, Base.show is only called once and everything works correctly.

Any ideas to fix this issue?