diff --git a/src/Plots.jl b/src/Plots.jl index ed00e38b..2e67ffaa 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -11,8 +11,6 @@ using Requires abstract PlottingPackage -immutable QwtPackage <: PlottingPackage end -immutable GadflyPackage <: PlottingPackage end const AVAILABLE_PACKAGES = [:Qwt, :Gadfly] const INITIALIZED_PACKAGES = Set{Symbol}() @@ -35,7 +33,8 @@ Setup the plot environment. Same for `plotter(:Gadfly)`, etc. """ function plotter(modname) - if modname == :Qwt + + if modname in (:Qwt, :qwt) if !(modname in INITIALIZED_PACKAGES) qwt() push!(INITIALIZED_PACKAGES, modname) @@ -43,7 +42,8 @@ function plotter(modname) global Qwt = Main.Qwt CURRENT_PACKAGE.pkg = Nullable(QwtPackage()) return - elseif modname == :Gadfly + + elseif modname in (:Gadfly, :gadfly) if !(modname in INITIALIZED_PACKAGES) gadfly() push!(INITIALIZED_PACKAGES, modname) @@ -51,6 +51,7 @@ function plotter(modname) global Gadfly = Main.Gadfly CURRENT_PACKAGE.pkg = Nullable(GadflyPackage()) return + end error("Unknown plotter $modname. Choose from: $AVAILABLE_PACKAGES") end diff --git a/src/gadfly.jl b/src/gadfly.jl index c81d2c01..03b0dcd7 100644 --- a/src/gadfly.jl +++ b/src/gadfly.jl @@ -1,5 +1,7 @@ -# Gadfly +# https://github.com/dcjones/Gadfly.jl + +immutable GadflyPackage <: PlottingPackage end plot(::GadflyPackage, y; kw...) = Gadfly.plot(; x = 1:length(y), y = y, kw...) plot(::GadflyPackage, x, y; kw...) = Gadfly.plot(; x = x, y = y, kw...) diff --git a/src/qwt.jl b/src/qwt.jl index de3e640c..809c5285 100644 --- a/src/qwt.jl +++ b/src/qwt.jl @@ -1,5 +1,7 @@ -# Qwt +# https://github.com/tbreloff/Qwt.jl + +immutable QwtPackage <: PlottingPackage end plot(::QwtPackage, args...; kw...) = Qwt.plot(args...; kw...) subplot(::QwtPackage, args...; kw...) = Qwt.subplot(args...; kw...) diff --git a/test/runtests.jl b/test/runtests.jl index a42bb8d8..a3665c09 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,7 +5,11 @@ using FactCheck facts("Qwt") do - + @fact plotter(:qwt) --> nothing +end + +facts("Gadfly") do + @fact plotter(:gadfly) --> nothing end end # module