diff --git a/src/Plots.jl b/src/Plots.jl index e45c6529..dd3522a3 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -186,10 +186,10 @@ yaxis!(plt::Plot, args...; kw...) = plot!(pl # --------------------------------------------------------- -try - import DataFrames - dataframes() -end +# try +# import DataFrames +# dataframes() +# end # const CURRENT_BACKEND = pickDefaultBackend() @@ -202,18 +202,21 @@ end # end # end +const CURRENT_BACKEND = CurrentBackend(:none) -function __init__() - global const CURRENT_BACKEND = pickDefaultBackend() - # global CURRENT_BACKEND - # println("[Plots.jl] Default backend: ", CURRENT_BACKEND.sym) +# function __init__() +# # global const CURRENT_BACKEND = pickDefaultBackend() +# # global const CURRENT_BACKEND = CurrentBackend(:none) - # # auto init dataframes if the import statement doesn't error out - # try - # @eval import DataFrames - # dataframes() - # end -end +# # global CURRENT_BACKEND +# # println("[Plots.jl] Default backend: ", CURRENT_BACKEND.sym) + +# # # auto init dataframes if the import statement doesn't error out +# # try +# # @eval import DataFrames +# # dataframes() +# # end +# end # --------------------------------------------------------- diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 72c20c00..66edeb54 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -568,7 +568,7 @@ function subplot(plts::AVec{Plot{PyPlotPackage}}, layout::SubplotLayout, d::Dict n = sum([plt.n for plt in plts]) pkg = PyPlotPackage() - newplts = Plot{PyPlotPackage}[plot(pkg; subplot=true, plt.plotargs...) for plt in plts] + newplts = Plot{PyPlotPackage}[_create_plot(pkg; subplot=true, plt.plotargs...) for plt in plts] subplt = Subplot(nothing, newplts, PyPlotPackage(), p, n, layout, d, true, false, false, (r,c) -> (nothing,nothing)) diff --git a/src/plotter.jl b/src/plotter.jl index 14673ff9..b4142500 100644 --- a/src/plotter.jl +++ b/src/plotter.jl @@ -8,6 +8,7 @@ immutable UnicodePlotsPackage <: PlottingPackage end immutable WinstonPackage <: PlottingPackage end immutable BokehPackage <: PlottingPackage end immutable PlotlyPackage <: PlottingPackage end +immutable NoPackage <: PlottingPackage end typealias GadflyOrImmerse @compat(Union{GadflyPackage, ImmersePackage}) @@ -37,6 +38,7 @@ backend_name(::UnicodePlotsPackage) = :unicodeplots backend_name(::QwtPackage) = :qwt backend_name(::BokehPackage) = :bokeh backend_name(::PlotlyPackage) = :plotly +backend_name(::NoPackage) = :none include("backends/supported.jl") @@ -81,6 +83,7 @@ function backendInstance(sym::Symbol) sym == :winston && return WinstonPackage() sym == :bokeh && return BokehPackage() sym == :plotly && return PlotlyPackage() + sym == :none && return NoPackage() error("Unsupported backend $sym") end @@ -93,39 +96,48 @@ CurrentBackend(sym::Symbol) = CurrentBackend(sym, backendInstance(sym)) # --------------------------------------------------------- +# function pickDefaultBackend() +# try +# if Pkg.installed("PyPlot") != nothing +# return CurrentBackend(:pyplot) +# end +# end +# try +# if Pkg.installed("Immerse") != nothing +# return CurrentBackend(:immerse) +# end +# end +# try +# if Pkg.installed("Qwt") != nothing +# return CurrentBackend(:qwt) +# end +# end +# try +# if Pkg.installed("Gadfly") != nothing +# return CurrentBackend(:gadfly) +# end +# end +# try +# if Pkg.installed("UnicodePlots") != nothing +# return CurrentBackend(:unicodeplots) +# end +# end +# try +# if Pkg.installed("Bokeh") != nothing +# return CurrentBackend(:bokeh) +# end +# end +# # warn("You don't have any of the supported backends installed! Chose from ", backends()) +# return CurrentBackend(:plotly) +# end + function pickDefaultBackend() - try - if Pkg.installed("PyPlot") != nothing - return CurrentBackend(:pyplot) + for pkgstr in ("PyPlot", "Immerse", "Qwt", "Gadfly", "UnicodePlots", "Bokeh") + if Pkg.installed(pkgstr) != nothing + return backend(symbol(lowercase(pkgstr))) end end - try - if Pkg.installed("Immerse") != nothing - return CurrentBackend(:immerse) - end - end - try - if Pkg.installed("Qwt") != nothing - return CurrentBackend(:qwt) - end - end - try - if Pkg.installed("Gadfly") != nothing - return CurrentBackend(:gadfly) - end - end - try - if Pkg.installed("UnicodePlots") != nothing - return CurrentBackend(:unicodeplots) - end - end - try - if Pkg.installed("Bokeh") != nothing - return CurrentBackend(:bokeh) - end - end - # warn("You don't have any of the supported backends installed! Chose from ", backends()) - return CurrentBackend(:plotly) + backend(:plotly) end @@ -136,6 +148,11 @@ Returns the current plotting package name. Initializes package on first call. """ function backend() + global CURRENT_BACKEND + if CURRENT_BACKEND.sym == :none + pickDefaultBackend() + end + currentBackendSymbol = CURRENT_BACKEND.sym if !(currentBackendSymbol in INITIALIZED_BACKENDS)