reexport Colors; move default backend choice into __init__; fixed pickDefaultBackend

This commit is contained in:
Thomas Breloff 2015-09-22 08:10:30 -04:00
parent f2bcb77cfb
commit f8fb473981
5 changed files with 30 additions and 16 deletions

View File

@ -1,3 +1,4 @@
julia 0.4- julia 0.4-
Colors Colors
Reexport

View File

@ -2,7 +2,8 @@ __precompile__()
module Plots module Plots
using Colors using Reexport
@reexport using Colors
export export
plotter, plotter,
@ -93,6 +94,11 @@ savepng(plt::PlottingObject, args...; kw...) = savepng(plt.plotter, plt, args...
savepng(::PlottingPackage, plt::PlottingObject, fn::AbstractString, args...) = error("unsupported") # fallback so multiple dispatch doesn't get confused if it's missing savepng(::PlottingPackage, plt::PlottingObject, fn::AbstractString, args...) = error("unsupported") # fallback so multiple dispatch doesn't get confused if it's missing
function __init__()
global const CURRENT_BACKEND = pickDefaultBackend()
println("[Plots.jl] Default backend: ", CURRENT_BACKEND.sym)
end
# --------------------------------------------------------- # ---------------------------------------------------------
end # module end # module

View File

@ -117,7 +117,7 @@ end
# Then once inputs have been converted, build the series args, map functions, etc. # Then once inputs have been converted, build the series args, map functions, etc.
# This should cut down on boilerplate code and allow more focused dispatch on type # This should cut down on boilerplate code and allow more focused dispatch on type
typealias FuncOrFuncs Union(Function, AVec{Function}) typealias FuncOrFuncs Union{Function, AVec{Function}}
# missing # missing
convertToAnyVector(v::Void; kw...) = Any[nothing] convertToAnyVector(v::Void; kw...) = Any[nothing]

View File

@ -48,34 +48,40 @@ CurrentBackend(sym::Symbol) = CurrentBackend(sym, backend(sym))
function pickDefaultBackend() function pickDefaultBackend()
try try
Pkg.installed("Immerse") if Pkg.installed("Immerse") != nothing
return CurrentBackend(:immerse) return CurrentBackend(:immerse)
end
end end
try try
Pkg.installed("Qwt") if Pkg.installed("Qwt") != nothing
return CurrentBackend(:qwt) return CurrentBackend(:qwt)
end
end end
try try
Pkg.installed("PyPlot") if Pkg.installed("PyPlot") != nothing
return CurrentBackend(:pyplot) return CurrentBackend(:pyplot)
end
end end
try try
Pkg.installed("Gadfly") if Pkg.installed("Gadfly") != nothing
return CurrentBackend(:gadfly) return CurrentBackend(:gadfly)
end
end end
try try
Pkg.installed("UnicodePlots") if Pkg.installed("UnicodePlots") != nothing
return CurrentBackend(:unicodeplots) return CurrentBackend(:unicodeplots)
end
end end
try try
Pkg.installed("Winston") if Pkg.installed("Winston") != nothing
return CurrentBackend(:winston) return CurrentBackend(:winston)
end
end end
warn("You don't have any of the supported backends installed! Chose from ", backends()) warn("You don't have any of the supported backends installed! Chose from ", backends())
return CurrentBackend(:gadfly) return CurrentBackend(:gadfly)
end end
const CURRENT_BACKEND = pickDefaultBackend() # const CURRENT_BACKEND = pickDefaultBackend()
println("[Plots.jl] Default backend: ", CURRENT_BACKEND.sym) # println("[Plots.jl] Default backend: ", CURRENT_BACKEND.sym)
# --------------------------------------------------------- # ---------------------------------------------------------

View File

@ -1,6 +1,7 @@
julia 0.4- julia 0.4-
Colors Colors
Reexport
FactCheck FactCheck
PyPlot PyPlot
UnicodePlots UnicodePlots