inline display

This commit is contained in:
Tom Breloff 2016-12-01 15:22:51 -05:00
parent 4ed7144ca4
commit b23d94eeb8
3 changed files with 20 additions and 6 deletions

View File

@ -57,6 +57,7 @@ export
savefig, savefig,
png, png,
gui, gui,
inline,
closeall, closeall,
backend, backend,

View File

@ -122,6 +122,13 @@ savefig(fn::AbstractString) = savefig(current(), fn)
gui(plt::Plot = current()) = display(PlotsDisplay(), plt) gui(plt::Plot = current()) = display(PlotsDisplay(), plt)
# IJulia only... inline display
function inline(plt::Plot = current())
isijulia() || error("inline() is IJulia-only")
Main.IJulia.clear_output(true)
display(Main.IJulia.InlineDisplay(), plt)
end
function Base.display(::PlotsDisplay, plt::Plot) function Base.display(::PlotsDisplay, plt::Plot)
prepare_output(plt) prepare_output(plt)
_display(plt) _display(plt)
@ -130,6 +137,13 @@ end
# override the REPL display to open a gui window # override the REPL display to open a gui window
Base.display(::Base.REPL.REPLDisplay, ::MIME"text/plain", plt::Plot) = gui(plt) Base.display(::Base.REPL.REPLDisplay, ::MIME"text/plain", plt::Plot) = gui(plt)
_do_plot_show(plt, showval::Bool) = showval && gui(plt)
function _do_plot_show(plt, showval::Symbol)
showval == :gui && gui(plt)
showval in (:inline,:ijulia) && inline(plt)
end
# --------------------------------------------------------- # ---------------------------------------------------------
const _mimeformats = Dict( const _mimeformats = Dict(

View File

@ -126,9 +126,7 @@ function plot(plt1::Plot, plts_tail::Plot...; kw...)
# finish up # finish up
current(plt) current(plt)
if get(d, :show, default(:show)) _do_plot_show(plt, get(d, :show, default(:show)))
gui()
end
plt plt
end end
@ -234,9 +232,10 @@ function _plot!(plt::Plot, d::KW, args::Tuple)
current(plt) current(plt)
# do we want to force display? # do we want to force display?
if plt[:show] # if plt[:show]
gui(plt) # gui(plt)
end # end
_do_plot_show(plt, plt[:show])
plt plt
end end