Skip to content

Instantly share code, notes, and snippets.

Created Apr 14, 2010
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)
;; add a LaTeX subtitle to the chart of the Normal PDF
(doto (function-plot pdf-normal -3 3)
(add-latex-subtitle eq)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment