diff --git a/src/Plots.jl b/src/Plots.jl index 424b632f..3f5a1d5e 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -69,6 +69,7 @@ export backend, backends, backend_name, + add_backend, aliases, dataframes, diff --git a/src/backends.jl b/src/backends.jl index aa8a7c9b..2313ef03 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -44,6 +44,9 @@ include("backends/web.jl") # --------------------------------------------------------- +add_backend(pkg::Symbol) = add_backend(_backend_instance(pkg)) +add_backend(b::AbstractBackend) = warn("No custom install defined for $(backend_name(b))") + # don't do anything as a default _create_backend_figure(plt::Plot) = nothing _prepare_plot_object(plt::Plot) = nothing diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 874c5c72..f59a8cc9 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -47,6 +47,11 @@ is_string_supported(::PlotlyBackend) = true # -------------------------------------------------------------------------------------- +function add_backend(::PlotlyBackend) + Pkg.build("Plots") +end + + const _plotly_js_path = joinpath(dirname(@__FILE__), "..", "..", "deps", "plotly-latest.min.js") function _initialize_backend(::PlotlyBackend; kw...) diff --git a/src/backends/plotlyjs.jl b/src/backends/plotlyjs.jl index a96587e6..3f2c6bad 100644 --- a/src/backends/plotlyjs.jl +++ b/src/backends/plotlyjs.jl @@ -11,6 +11,17 @@ is_string_supported(::PlotlyJSBackend) = true # -------------------------------------------------------------------------------------- + +function add_backend(::PlotlyJSBackend) + if !is_installed("PlotlyJS") + Pkg.add("PlotlyJS") + @eval import Blink + Blink.AtomShell.install() + Pkg.add("Rsvg") + end +end + + function _initialize_backend(::PlotlyJSBackend; kw...) @eval begin import PlotlyJS diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 2b0d748a..4bb074bb 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -47,6 +47,14 @@ is_subplot_supported(::PyPlotBackend) = true # -------------------------------------------------------------------------------------- +function add_backend(::PyPlotBackend) + if !is_installed("PyPlot") + withenv("PYTHON" => "") do + Pkg.add("PyPlot") + Pkg.build("PyPlot") + end + end +end function _initialize_backend(::PyPlotBackend) @eval begin diff --git a/src/output.jl b/src/output.jl index 8474223d..f92d8047 100644 --- a/src/output.jl +++ b/src/output.jl @@ -255,9 +255,15 @@ function setup_atom() # @eval import Atom, Media @eval import Atom + # default text/plain passes to html... handles Interact issues + function Base.show(io::IO, m::MIME"text/plain", plt::Plot) + show(io, MIME("text/html"), plt) + end + # for inline values, display the plot (gui) and return a graph icon function Atom.Media.render(::Atom.Inline, plt::Plot) - display(PlotsDisplay(), plt) + # info("using Media.render") + display(plt) Atom.icon("graph") end