From 7fb1a4ec0fdd7de3e82671ac1f40c0d777077220 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Sat, 12 Sep 2015 16:10:42 -0400 Subject: [PATCH] better error when importing a package that is not installed; xmin/xmax functions example --- docs/example_generation.jl | 5 ++++- src/plotter.jl | 22 +++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/docs/example_generation.jl b/docs/example_generation.jl index df569e9c..3e69693f 100644 --- a/docs/example_generation.jl +++ b/docs/example_generation.jl @@ -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)))]), diff --git a/src/plotter.jl b/src/plotter.jl index edacdbfc..1d20b965 100644 --- a/src/plotter.jl +++ b/src/plotter.jl @@ -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