new init logic; fix pyplot subplot bug
This commit is contained in:
parent
e92b5b2d35
commit
75adfd2e9d
31
src/Plots.jl
31
src/Plots.jl
@ -186,10 +186,10 @@ yaxis!(plt::Plot, args...; kw...) = plot!(pl
|
|||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
try
|
# try
|
||||||
import DataFrames
|
# import DataFrames
|
||||||
dataframes()
|
# dataframes()
|
||||||
end
|
# end
|
||||||
|
|
||||||
# const CURRENT_BACKEND = pickDefaultBackend()
|
# const CURRENT_BACKEND = pickDefaultBackend()
|
||||||
|
|
||||||
@ -202,18 +202,21 @@ end
|
|||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
const CURRENT_BACKEND = CurrentBackend(:none)
|
||||||
|
|
||||||
function __init__()
|
# function __init__()
|
||||||
global const CURRENT_BACKEND = pickDefaultBackend()
|
# # global const CURRENT_BACKEND = pickDefaultBackend()
|
||||||
# global CURRENT_BACKEND
|
# # global const CURRENT_BACKEND = CurrentBackend(:none)
|
||||||
# println("[Plots.jl] Default backend: ", CURRENT_BACKEND.sym)
|
|
||||||
|
|
||||||
# # auto init dataframes if the import statement doesn't error out
|
# # global CURRENT_BACKEND
|
||||||
# try
|
# # println("[Plots.jl] Default backend: ", CURRENT_BACKEND.sym)
|
||||||
# @eval import DataFrames
|
|
||||||
# dataframes()
|
# # # auto init dataframes if the import statement doesn't error out
|
||||||
# end
|
# # try
|
||||||
end
|
# # @eval import DataFrames
|
||||||
|
# # dataframes()
|
||||||
|
# # end
|
||||||
|
# end
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -568,7 +568,7 @@ function subplot(plts::AVec{Plot{PyPlotPackage}}, layout::SubplotLayout, d::Dict
|
|||||||
n = sum([plt.n for plt in plts])
|
n = sum([plt.n for plt in plts])
|
||||||
|
|
||||||
pkg = PyPlotPackage()
|
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))
|
subplt = Subplot(nothing, newplts, PyPlotPackage(), p, n, layout, d, true, false, false, (r,c) -> (nothing,nothing))
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@ immutable UnicodePlotsPackage <: PlottingPackage end
|
|||||||
immutable WinstonPackage <: PlottingPackage end
|
immutable WinstonPackage <: PlottingPackage end
|
||||||
immutable BokehPackage <: PlottingPackage end
|
immutable BokehPackage <: PlottingPackage end
|
||||||
immutable PlotlyPackage <: PlottingPackage end
|
immutable PlotlyPackage <: PlottingPackage end
|
||||||
|
immutable NoPackage <: PlottingPackage end
|
||||||
|
|
||||||
typealias GadflyOrImmerse @compat(Union{GadflyPackage, ImmersePackage})
|
typealias GadflyOrImmerse @compat(Union{GadflyPackage, ImmersePackage})
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ backend_name(::UnicodePlotsPackage) = :unicodeplots
|
|||||||
backend_name(::QwtPackage) = :qwt
|
backend_name(::QwtPackage) = :qwt
|
||||||
backend_name(::BokehPackage) = :bokeh
|
backend_name(::BokehPackage) = :bokeh
|
||||||
backend_name(::PlotlyPackage) = :plotly
|
backend_name(::PlotlyPackage) = :plotly
|
||||||
|
backend_name(::NoPackage) = :none
|
||||||
|
|
||||||
include("backends/supported.jl")
|
include("backends/supported.jl")
|
||||||
|
|
||||||
@ -81,6 +83,7 @@ function backendInstance(sym::Symbol)
|
|||||||
sym == :winston && return WinstonPackage()
|
sym == :winston && return WinstonPackage()
|
||||||
sym == :bokeh && return BokehPackage()
|
sym == :bokeh && return BokehPackage()
|
||||||
sym == :plotly && return PlotlyPackage()
|
sym == :plotly && return PlotlyPackage()
|
||||||
|
sym == :none && return NoPackage()
|
||||||
error("Unsupported backend $sym")
|
error("Unsupported backend $sym")
|
||||||
end
|
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()
|
function pickDefaultBackend()
|
||||||
try
|
for pkgstr in ("PyPlot", "Immerse", "Qwt", "Gadfly", "UnicodePlots", "Bokeh")
|
||||||
if Pkg.installed("PyPlot") != nothing
|
if Pkg.installed(pkgstr) != nothing
|
||||||
return CurrentBackend(:pyplot)
|
return backend(symbol(lowercase(pkgstr)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
try
|
backend(:plotly)
|
||||||
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
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -136,6 +148,11 @@ Returns the current plotting package name. Initializes package on first call.
|
|||||||
"""
|
"""
|
||||||
function backend()
|
function backend()
|
||||||
|
|
||||||
|
global CURRENT_BACKEND
|
||||||
|
if CURRENT_BACKEND.sym == :none
|
||||||
|
pickDefaultBackend()
|
||||||
|
end
|
||||||
|
|
||||||
currentBackendSymbol = CURRENT_BACKEND.sym
|
currentBackendSymbol = CURRENT_BACKEND.sym
|
||||||
if !(currentBackendSymbol in INITIALIZED_BACKENDS)
|
if !(currentBackendSymbol in INITIALIZED_BACKENDS)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user