Skip to content

Instantly share code, notes, and snippets.

@liebke
Created April 14, 2010 03:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liebke/2f99f799e11c98a33ec9 to your computer and use it in GitHub Desktop.
Save liebke/2f99f799e11c98a33ec9 to your computer and use it in GitHub Desktop.
;; 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