% Intro to Weave.jl with Gadfly % Matti Pastell % 20th April 2016 # Introduction This a sample [Julia](http://julialang.org/) noweb document that can be executed using [Weave.jl](https://github.com/JunoLab/Weave.jl). The code is delimited from docs using `<<>>=` and `@` markup which can be seen looking at the source document `gadfly_sample.mdw` in the examples directory of the package. The source document can be executed and the results with Gadfly plots are captured in the resulting file. You can create markdown output or pdf and HTML directly (with Pandoc) using the weave command as follows: ```julia using Weave #Markdown weave(Pkg.dir("Weave","examples","gadfly_sample.mdw"), out_path = :pwd, doctype = "pandoc") #HTML weave(Pkg.dir("Weave","examples","gadfly_sample.mdw"), out_path = :pwd, doctype = "md2html") #pdf weave(Pkg.dir("Weave","examples","gadfly_sample.mdw"), out_path = :pwd, doctype = "md2pdf") ``` *The documents will be written to the Julia working directory when you use the `out_path = :pwd`.* # Capturing code The basic code chunk will be run with default options and the code and output will be captured. <<>>= using Gadfly x = linspace(0, 2*pi) println(x) plot(x = x, y = sin(x)) @ You can also control the way the results are captured, plot size etc. using chunk options. Here is an example of a chunk that behaves like a repl. <>= x = 1:10 d = Dict("Weave" => "testing") y = [2, 4 ,8] @ You can also for instance hide the code and show only the figure, add a caption to the figure and make it wider as follows (you can only see the syntax from the source document): <>= plot(y = cumsum(randn(1000, 1)), Geom.line) @ # Whats next Read the documentation: - stable: - latest: See other examples in: