diff --git a/src/Plots.jl b/src/Plots.jl index 65434b81..9b4bcb10 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -57,6 +57,7 @@ export savefig, png, gui, + inline, closeall, backend, diff --git a/src/output.jl b/src/output.jl index 0f4b01ae..ff4a1def 100644 --- a/src/output.jl +++ b/src/output.jl @@ -122,6 +122,13 @@ savefig(fn::AbstractString) = savefig(current(), fn) 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) prepare_output(plt) _display(plt) @@ -130,6 +137,13 @@ end # override the REPL display to open a gui window 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( diff --git a/src/plot.jl b/src/plot.jl index 498135f6..2e8063af 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -126,9 +126,7 @@ function plot(plt1::Plot, plts_tail::Plot...; kw...) # finish up current(plt) - if get(d, :show, default(:show)) - gui() - end + _do_plot_show(plt, get(d, :show, default(:show))) plt end @@ -234,9 +232,10 @@ function _plot!(plt::Plot, d::KW, args::Tuple) current(plt) # do we want to force display? - if plt[:show] - gui(plt) - end + # if plt[:show] + # gui(plt) + # end + _do_plot_show(plt, plt[:show]) plt end