examples
@ -4,6 +4,7 @@ module PlotExamples
|
|||||||
using Plots
|
using Plots
|
||||||
|
|
||||||
const DOCDIR = Pkg.dir("Plots") * "/docs"
|
const DOCDIR = Pkg.dir("Plots") * "/docs"
|
||||||
|
const IMGDIR = Pkg.dir("Plots") * "/img"
|
||||||
|
|
||||||
doc"""
|
doc"""
|
||||||
Holds all data needed for a documentation example... header, description, and plotting expression (Expr)
|
Holds all data needed for a documentation example... header, description, and plotting expression (Expr)
|
||||||
@ -14,7 +15,9 @@ type PlotExample
|
|||||||
expr::Expr
|
expr::Expr
|
||||||
end
|
end
|
||||||
|
|
||||||
examples = PlotExample[
|
|
||||||
|
# the examples we'll run for each
|
||||||
|
const examples = PlotExample[
|
||||||
PlotExample("Lines",
|
PlotExample("Lines",
|
||||||
"A simple line plot of the 3 columns.",
|
"A simple line plot of the 3 columns.",
|
||||||
:(plot(rand(100,3)))),
|
:(plot(rand(100,3)))),
|
||||||
@ -33,9 +36,41 @@ examples = PlotExample[
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
function generate_markdown(modname)
|
function generate_markdown(pkgname::Symbol)
|
||||||
plotter!(modname)
|
|
||||||
|
# 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, "\n\n")
|
||||||
|
|
||||||
|
catch ex
|
||||||
|
# TODO: put error info into markdown?
|
||||||
|
warn("Example $pkgname:$i failed with: $ex")
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
end
|
||||||
|
|
||||||
|
close(md)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# run it!
|
# run it!
|
||||||
|
|||||||
40
docs/gadfly_examples.md
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
### Lines
|
||||||
|
|
||||||
|
A simple line plot of the 3 columns.
|
||||||
|
|
||||||
|
```julia
|
||||||
|
plot(rand(100,3))
|
||||||
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Global
|
||||||
|
|
||||||
|
Change the guides/background without a separate call.
|
||||||
|
|
||||||
|
```julia
|
||||||
|
plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=:red)
|
||||||
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Vectors
|
||||||
|
|
||||||
|
Plot multiple series with different numbers of points.
|
||||||
|
|
||||||
|
```julia
|
||||||
|
plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8)
|
||||||
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### 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])
|
||||||
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
40
docs/qwt_examples.md
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
### Lines
|
||||||
|
|
||||||
|
A simple line plot of the 3 columns.
|
||||||
|
|
||||||
|
```julia
|
||||||
|
plot(rand(100,3))
|
||||||
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Global
|
||||||
|
|
||||||
|
Change the guides/background without a separate call.
|
||||||
|
|
||||||
|
```julia
|
||||||
|
plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=:red)
|
||||||
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Vectors
|
||||||
|
|
||||||
|
Plot multiple series with different numbers of points.
|
||||||
|
|
||||||
|
```julia
|
||||||
|
plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8)
|
||||||
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### 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])
|
||||||
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
BIN
img/gadfly_example_1.png
Normal file
|
After Width: | Height: | Size: 78 KiB |
BIN
img/gadfly_example_3.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
img/gadfly_example_4.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
img/gadfly_example_5.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
img/qwt_example_1.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
img/qwt_example_3.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
img/qwt_example_4.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
img/qwt_example_5.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
@ -31,7 +31,7 @@ typealias AMat AbstractMatrix
|
|||||||
|
|
||||||
abstract PlottingPackage
|
abstract PlottingPackage
|
||||||
|
|
||||||
const IMG_DIR = "$(ENV["HOME"])/.julia/v0.4/Plots/img/"
|
const IMG_DIR = Pkg.dir("Plots") * "/img/"
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|||||||