Weave.jl/examples/winston_sample.mdw

58 lines
1.2 KiB
Plaintext

# Introducion to Weave
This a sample [Julia](http://julialang.org/) noweb document that can
be executed using Weave. Output from code chunks and Winston
plots will be included in the weaved document. You also need to install Pweave from Github in order to use Weave.
This documented can be turned into Pandoc markdown with captured
result from Julia prompt.
~~~~{.julia}
using Weave
weave(Pkg.dir("Weave","examples","winston_sample.mdw"), plotlib="Winston")
~~~~
## Terminal chunk
<<term=true>>=
x = 1:10
d = Dict("Weave" => "testing")
y = [2, 4 ,8]
@
## Capturing figures
The figures and code can be included in the output.
<<term=true>>=
using Winston
t = linspace(0, 2*pi, 100)
p = plot(t, sinc(t))
@
You can also include a plot with caption and hide the code:
<<echo=false; fig_cap="Random walk."; label="random"; fig_width=8; fig_height=4>>=
p = plot(cumsum(randn(1000, 1)))
xlabel("x")
ylabel("sinc(x)")
display(p)
@
<<>>=
x = linspace(0, 3pi, 100)
c = cos(x)
s = sin(x)
p = FramedPlot(
title="title!",
xlabel="\\Sigma x^2_i",
ylabel="\\Theta_i")
add(p, FillBetween(x, c, x, s))
add(p, Curve(x, c, color="red"))
add(p, Curve(x, s, color="blue"))
display(p)
@