diff --git a/docs/example_generation.jl b/docs/example_generation.jl index 360f790f..1bb9fc0f 100644 --- a/docs/example_generation.jl +++ b/docs/example_generation.jl @@ -4,6 +4,7 @@ module PlotExamples using Plots const DOCDIR = Pkg.dir("Plots") * "/docs" +const IMGDIR = Pkg.dir("Plots") * "/img" doc""" Holds all data needed for a documentation example... header, description, and plotting expression (Expr) @@ -14,7 +15,9 @@ type PlotExample expr::Expr end -examples = PlotExample[ + +# the examples we'll run for each +const examples = PlotExample[ PlotExample("Lines", "A simple line plot of the 3 columns.", :(plot(rand(100,3)))), @@ -33,9 +36,41 @@ examples = PlotExample[ ] -function generate_markdown(modname) - plotter!(modname) - +function generate_markdown(pkgname::Symbol) + + # set up the plotter, and don't show the plots by default + plotter!(pkgname) + + + # open the markdown file + md = open("$DOCDIR/$(pkgname)_examples.md", "w") + + for (i,example) in enumerate(examples) + + try + + # run the code + eval(example.expr) + + # save the png + imgname = "$(pkgname)_example_$i.png" + savepng("$IMGDIR/$imgname") + + write(md, "### $(example.header)\n\n") + write(md, "$(example.desc)\n\n") + write(md, "```julia\n$(string(example.expr))\n```\n\n") + write(md, "![](../$imgname)\n\n") + + catch ex + # TODO: put error info into markdown? + warn("Example $pkgname:$i failed with: $ex") + end + + # + end + + close(md) + end # run it! diff --git a/docs/gadfly_examples.md b/docs/gadfly_examples.md new file mode 100644 index 00000000..1656fb14 --- /dev/null +++ b/docs/gadfly_examples.md @@ -0,0 +1,40 @@ +### Lines + +A simple line plot of the 3 columns. + +```julia +plot(rand(100,3)) +``` + +![](../gadfly_example_1.png) + +### Global + +Change the guides/background without a separate call. + +```julia +plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=:red) +``` + +![](../gadfly_example_3.png) + +### Vectors + +Plot multiple series with different numbers of points. + +```julia +plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8) +``` + +![](../gadfly_example_4.png) + +### Vectors w/ pluralized args + +Mix arguments that apply to all series with arguments unique to each series. + +```julia +plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,markercolors=[:red,:blue]) +``` + +![](../gadfly_example_5.png) + diff --git a/docs/qwt_examples.md b/docs/qwt_examples.md new file mode 100644 index 00000000..ec24bea2 --- /dev/null +++ b/docs/qwt_examples.md @@ -0,0 +1,40 @@ +### Lines + +A simple line plot of the 3 columns. + +```julia +plot(rand(100,3)) +``` + +![](../qwt_example_1.png) + +### Global + +Change the guides/background without a separate call. + +```julia +plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=:red) +``` + +![](../qwt_example_3.png) + +### Vectors + +Plot multiple series with different numbers of points. + +```julia +plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8) +``` + +![](../qwt_example_4.png) + +### Vectors w/ pluralized args + +Mix arguments that apply to all series with arguments unique to each series. + +```julia +plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,markercolors=[:red,:blue]) +``` + +![](../qwt_example_5.png) + diff --git a/img/gadfly_example_1.png b/img/gadfly_example_1.png new file mode 100644 index 00000000..0e78cf2d Binary files /dev/null and b/img/gadfly_example_1.png differ diff --git a/img/gadfly_example_3.png b/img/gadfly_example_3.png new file mode 100644 index 00000000..dbb41fd2 Binary files /dev/null and b/img/gadfly_example_3.png differ diff --git a/img/gadfly_example_4.png b/img/gadfly_example_4.png new file mode 100644 index 00000000..e11b7a91 Binary files /dev/null and b/img/gadfly_example_4.png differ diff --git a/img/gadfly_example_5.png b/img/gadfly_example_5.png new file mode 100644 index 00000000..6ec63145 Binary files /dev/null and b/img/gadfly_example_5.png differ diff --git a/img/qwt_example_1.png b/img/qwt_example_1.png new file mode 100644 index 00000000..8a19bc15 Binary files /dev/null and b/img/qwt_example_1.png differ diff --git a/img/qwt_example_3.png b/img/qwt_example_3.png new file mode 100644 index 00000000..4691cc91 Binary files /dev/null and b/img/qwt_example_3.png differ diff --git a/img/qwt_example_4.png b/img/qwt_example_4.png new file mode 100644 index 00000000..f337eedf Binary files /dev/null and b/img/qwt_example_4.png differ diff --git a/img/qwt_example_5.png b/img/qwt_example_5.png new file mode 100644 index 00000000..68d3e077 Binary files /dev/null and b/img/qwt_example_5.png differ diff --git a/src/Plots.jl b/src/Plots.jl index 4d07c571..7109ff46 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -31,7 +31,7 @@ typealias AMat AbstractMatrix abstract PlottingPackage -const IMG_DIR = "$(ENV["HOME"])/.julia/v0.4/Plots/img/" +const IMG_DIR = Pkg.dir("Plots") * "/img/" # ---------------------------------------------------------