better error when importing a package that is not installed; xmin/xmax functions example

This commit is contained in:
Thomas Breloff 2015-09-12 16:10:42 -04:00
parent 4299aa0ff8
commit 7fb1a4ec0f
2 changed files with 21 additions and 6 deletions

View File

@ -23,8 +23,11 @@ const examples = PlotExample[
"A simple line plot of the 3 columns.",
[:(plot(rand(100,3)))]),
PlotExample("Functions",
"Plot multiple functions",
"Plot multiple functions.",
[:(plot(0:0.01:4π, [sin,cos]))]),
PlotExample("",
"You can also call it with (xmin, xmax).",
[:(plot([sin,cos], 0, 4π))]),
PlotExample("Global",
"Change the guides/background without a separate call.",
[:(plot(rand(10); title="TITLE", xlabel="XLABEL", ylabel="YLABEL", background_color = RGB(0.5,0.5,0.5)))]),

View File

@ -34,18 +34,30 @@ function plotter()
if !(currentPackageSymbol in INITIALIZED_PACKAGES)
# initialize
print("[Plots.jl] Initializing package: $CURRENT_PACKAGE... ")
println("[Plots.jl] Initializing package: $CURRENT_PACKAGE... ")
if currentPackageSymbol == :qwt
@eval import Qwt
try
@eval import Qwt
catch
error("Couldn't import Qwt. Install it with: Pkg.clone(\"https://github.com/tbreloff/Qwt.jl.git\")\n (Note: also requires pyqt and pyqwt)")
end
elseif currentPackageSymbol == :gadfly
@eval import Gadfly
try
@eval import Gadfly
catch
error("Couldn't import Gadfly. Install it with: Pkg.add(\"Gadfly\")")
end
elseif currentPackageSymbol == :unicodeplots
@eval import UnicodePlots
try
@eval import UnicodePlots
catch
error("Couldn't import UnicodePlots. Install it with: Pkg.add(\"UnicodePlots\")")
end
else
error("Unknown plotter $currentPackageSymbol. Choose from: $AVAILABLE_PACKAGES")
end
push!(INITIALIZED_PACKAGES, currentPackageSymbol)
println("done.")
println("[Plots.jl] done.")
end
CURRENT_PACKAGE.pkg