From 00660a63321d5610b243703a461f22d70931e3df Mon Sep 17 00:00:00 2001 From: Matti Pastell Date: Thu, 8 Jan 2015 23:45:26 +0200 Subject: [PATCH] Fix to caching, extended Gadfly with PGF example --- examples/gadfly_pgf.texw | 65 ++++++++++++++++++++++++++++++++++++++-- src/run.jl | 2 +- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/examples/gadfly_pgf.texw b/examples/gadfly_pgf.texw index 0e62caf..fdd237d 100644 --- a/examples/gadfly_pgf.texw +++ b/examples/gadfly_pgf.texw @@ -1,24 +1,83 @@ \documentclass{article} -\usepackage{pgfplots} + +%Minted for syntax hightlighting \usepackage{minted} + +%These are for plots +\usepackage{pgfplots} \usepackage{fontspec} +\setmainfont{TeX Gyre Pagella} \usepackage{amsmath} \usepackage[active,tightpage]{preview} + +%Hyperlinks +\usepackage{hyperref} +\hypersetup{colorlinks=true, urlcolor=blue} +%Some style changes +\setlength{\parindent}{0in} +\setlength{\parskip}{12pt} + + +\author{Matti Pastell} +\title{Using PGF plots with Weave and Gadfly} + \begin{document} + +\maketitle + +\section{Intro} + +This is a minimal example on using PGF format with Gadfly plots in +\href{https://github.com/mpastell/Weave.jl}{Weave.jl} document. +The source is in github: + +\url{https://github.com/mpastell/Weave.jl/blob/master/examples/gadfly_pgf.texw}. + +You can run this example with first weaving it from Julia using: + +<>= +using Weave +weave(Pkg.dir("Weave", "examples", "gadfly_pgf.texw"), + doctype="texminted", out_path=:pwd, fig_ext=".tex") +@ + +which will save the generated output in your working directory and use minted +package for syntax hightlighting. You'll need to use either xetex or luatex with +\texttt{-shell-escape} flag to get pdf e.g. + +\begin{minted}{bash} +$ lualatex -shell-escape gadfly_pgf.tex +\end{minted} + +\section{Sample code} + +You can set the default font in Gadfly to match the font in the document. +Use the \texttt{fontspec} latex package (see preamble) and define the +defaults to Gadfly as follows. + +If you want you can hide the chunk using the \texttt{echo=false} chunk option. + <<>>= using Gadfly Gadfly.default_theme.major_label_font = "Tex Gyre Pagella" Gadfly.default_theme.minor_label_font = "Tex Gyre Pagella" +Gadfly.default_theme.major_label_color = color("black") +Gadfly.default_theme.minor_label_color = color("black") +@ + +Let's create a simple plot: + +<<>>= x = 1:10 plot(x=x, y=x) @ +And a figure with a caption + <>= plot([sin, cos], 0, 25) @ - - \end{document} diff --git a/src/run.jl b/src/run.jl index dab9d14..3030da4 100644 --- a/src/run.jl +++ b/src/run.jl @@ -42,7 +42,7 @@ function Base.run(doc::WeaveDoc; doctype = "pandoc", plotlib="Gadfly", informat= report = Report(doc.cwd, doc.basename, doc.format.formatdict) pushdisplay(report) - if cache != :off || cache != :refresh + if cache != :off && cache != :refresh cached = read_cache(doc, cache_path) cached == nothing && info("No cached results found, running code") else