diff --git a/src/examples.jl b/src/examples.jl index a53707d9..762d857c 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -443,6 +443,7 @@ _backend_skips = Dict( :gr => [25, 30], :pyplot => [25, 30], :plotlyjs => [2, 21, 25, 30, 31], + :pgfplots => [2, 25, 30], ) # --------------------------------------------------------------------------------- diff --git a/src/init.jl b/src/init.jl index 08d1dd2b..545f55ea 100644 --- a/src/init.jl +++ b/src/init.jl @@ -80,4 +80,28 @@ function __init__() ENV["MPLBACKEND"] = "Agg" end end + + + + # --------------------------------------------------------- + # A backup, if no PNG generation is defined, is to try to make a PDF and use FileIO to convert + @require FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" begin + PDFBackends = Union{PGFPlotsBackend,PlotlyJSBackend,PyPlotBackend,InspectDRBackend,GRBackend} + function _show(io::IO, ::MIME"image/png", plt::Plot{<:PDFBackends}) + fn = tempname() + + # first save a pdf file + pdf(plt, fn) + + # load that pdf into a FileIO Stream + s = FileIO.load(fn * ".pdf") + + # save a png + pngfn = fn * ".png" + FileIO.save(pngfn, s) + + # now write from the file + write(io, read(open(pngfn), String)) + end + end end diff --git a/src/output.jl b/src/output.jl index 1122ab93..df6e3b84 100644 --- a/src/output.jl +++ b/src/output.jl @@ -210,30 +210,6 @@ _show(io::IO, ::MIME{Symbol("text/plain")}, plt::Plot) = show(io, plt) closeall() = closeall(backend()) -# --------------------------------------------------------- -# A backup, if no PNG generation is defined, is to try to make a PDF and use FileIO to convert - -const PDFBackends = Union{PGFPlotsBackend,PlotlyJSBackend,PyPlotBackend,InspectDRBackend,GRBackend} -if is_installed("FileIO") - @eval import FileIO - function _show(io::IO, ::MIME"image/png", plt::Plot{<:PDFBackends}) - fn = tempname() - - # first save a pdf file - pdf(plt, fn) - - # load that pdf into a FileIO Stream - s = FileIO.load(fn * ".pdf") - - # save a png - pngfn = fn * ".png" - FileIO.save(pngfn, s) - - # now write from the file - write(io, read(open(pngfn), String)) - end -end - # function html_output_format(fmt) # if fmt == "png" # @eval function Base.show(io::IO, ::MIME"text/html", plt::Plot) diff --git a/test/imgcomp.jl b/test/imgcomp.jl index 64bfbeb2..526d695e 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -29,11 +29,7 @@ default(size=(500,300)) # TODO: use julia's Condition type and the wait() and notify() functions to initialize a Window, then wait() on a condition that # is referenced in a button press callback (the button clicked callback will call notify() on that condition) -<<<<<<< HEAD -const _current_plots_version = v"0.20.3" -======= import Plots._current_plots_version ->>>>>>> move _current_plots_version from PlotDocs to Plots function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = isinteractive(), sigma = [1,1], tol = 1e-2)