pyplot gui fixes and background/foreground fixes with writemime
This commit is contained in:
parent
1c556ade57
commit
a9b39fad64
@ -511,9 +511,17 @@ end
|
||||
# end
|
||||
|
||||
|
||||
function Base.display(::PlotsDisplay, plt::Plot{PyPlotPackage})
|
||||
# NOTE: to bring up a GUI window in IJulia, need some extra steps
|
||||
function Base.display(::PlotsDisplay, plt::PlottingObject{PyPlotPackage})
|
||||
finalizePlot(plt)
|
||||
display(getfig(plt.o))
|
||||
if isa(Base.Multimedia.displays[end], Base.REPL.REPLDisplay)
|
||||
display(getfig(plt.o))
|
||||
else
|
||||
PyPlot.ion()
|
||||
PyPlot.figure(getfig(plt.o).o[:number])
|
||||
PyPlot.draw_if_interactive()
|
||||
PyPlot.ioff()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -524,20 +532,47 @@ function finalizePlot(subplt::Subplot{PyPlotPackage})
|
||||
end
|
||||
end
|
||||
|
||||
function Base.display(::PlotsDisplay, subplt::Subplot{PyPlotPackage})
|
||||
finalizePlot(subplt)
|
||||
display(getfig(subplt.o))
|
||||
end
|
||||
# function Base.display(::PlotsDisplay, subplt::Subplot{PyPlotPackage})
|
||||
# finalizePlot(subplt)
|
||||
# PyPlot.ion()
|
||||
# PyPlot.figure(getfig(subplt.o).o[:number])
|
||||
# PyPlot.draw_if_interactive()
|
||||
# PyPlot.ioff()
|
||||
# # display(getfig(subplt.o))
|
||||
# end
|
||||
|
||||
# allow for writing any supported mime
|
||||
for mime in (MIME"image/png", MIME"application/pdf", MIME"application/postscript")
|
||||
@eval function Base.writemime(io::IO, ::$mime, plt::PlottingObject{PyPlotPackage})
|
||||
# # allow for writing any supported mime
|
||||
# for mime in (MIME"image/png", MIME"application/pdf", MIME"application/postscript")
|
||||
# @eval function Base.writemime(io::IO, ::$mime, plt::PlottingObject{PyPlotPackage})
|
||||
# finalizePlot(plt)
|
||||
# writemime(io, $mime(), getfig(plt.o))
|
||||
# end
|
||||
# end
|
||||
|
||||
const _pyplot_mimeformats = @compat Dict(
|
||||
"application/eps" => "eps",
|
||||
"image/eps" => "eps",
|
||||
"application/pdf" => "pdf",
|
||||
"image/png" => "png",
|
||||
"application/postscript" => "ps",
|
||||
# "image/svg+xml" => "svg"
|
||||
)
|
||||
|
||||
|
||||
for (mime, fmt) in _pyplot_mimeformats
|
||||
@eval function Base.writemime(io::IO, ::MIME{symbol($mime)}, plt::PlottingObject{PyPlotPackage})
|
||||
finalizePlot(plt)
|
||||
writemime(io, $mime(), getfig(plt.o))
|
||||
fig = getfig(plt.o)
|
||||
fig.o["canvas"][:print_figure](io,
|
||||
format=$fmt,
|
||||
bbox_inches="tight",
|
||||
facecolor = fig.o["get_facecolor"](),
|
||||
edgecolor = "none"
|
||||
# edgecolor = fig.o["get_edgecolor"]()
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# function Base.writemime(io::IO, m::MIME"image/png", subplt::Subplot{PyPlotPackage})
|
||||
# finalizePlot(subplt)
|
||||
# writemime(io, m, getfig(subplt.o))
|
||||
|
||||
@ -160,6 +160,7 @@ function backend()
|
||||
# @eval const pycolorbar = PyPlot.pywrap(PyPlot.pyimport("matplotlib.colorbar"))
|
||||
if !isa(Base.Multimedia.displays[end], Base.REPL.REPLDisplay)
|
||||
PyPlot.ioff()
|
||||
PyPlot.pygui(true)
|
||||
end
|
||||
catch err
|
||||
warn("Couldn't import PyPlot. Install it with: Pkg.add(\"PyPlot\").")
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
|
||||
# include this first to help with crashing??
|
||||
using Gtk
|
||||
|
||||
# macro test_approx_eq_sigma_eps(A, B, sigma, eps)
|
||||
|
||||
include("../docs/example_generation.jl")
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 54 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 76 KiB |
Loading…
x
Reference in New Issue
Block a user