Skip to content

Instantly share code, notes, and snippets.

@liebke liebke/latexchart.clj Secret
Created Apr 14, 2010

Embed
What would you like to do?
;; The following examples require Incanter version 1.2.2-SNAPSHOT or greater.
;; add the following dependency to your project.clj file:
;; [incanter "1.2.2-SNAPSHOT"]
(use '(incanter core stats charts latex))
;; define the latex formatted equation.
;; use the str function so you can break the equation across multiple lines.
(def eq (str "f(x)=\\frac{1}{\\sqrt{2\\pi \\sigma^2}}"
"e^{\\frac{-(x - \\mu)^2}{2 \\sigma^2}}"))
;; the rendered equation can be viewed or saved as a png file.
(view (latex eq))
(save (latex eq) filename)
;; annotate a chart of the Normal PDF with the its equation in LaTeX
(doto (function-plot pdf-normal -3 3)
(add-latex 0 0.1 eq)
view)
;; add a LaTeX subtitle to the chart of the Normal PDF
(doto (function-plot pdf-normal -3 3)
(add-latex-subtitle eq)
view)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.