This commit is contained in:
Thomas Breloff 2015-09-10 14:46:57 -04:00
parent 378c85675b
commit 27b1fea1a3
12 changed files with 120 additions and 5 deletions

View File

@ -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!

40
docs/gadfly_examples.md Normal file
View File

@ -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)

40
docs/qwt_examples.md Normal file
View File

@ -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)

BIN
img/gadfly_example_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

BIN
img/gadfly_example_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
img/gadfly_example_4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
img/gadfly_example_5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
img/qwt_example_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
img/qwt_example_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
img/qwt_example_4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
img/qwt_example_5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -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/"
# ---------------------------------------------------------