Skip to content
This repository

Analemma is a Clojure library for generating charts and Scalable Vector Graphics (SVG)

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 images
Octocat-spinner-32 src
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.textile
Octocat-spinner-32 index.html
Octocat-spinner-32 project.clj
README.textile

Analemma is a Clojure-based SVG DSL and charting library. In astronomy, an analemma is the figure drawn in the sky by the different positions of the Sun recorded at the same time and location during the course of a year.

Example Charts

Plotting Analemma Data


(spit "analemma.svg"
      (emit-svg
        (-> (xy-plot :xmin -30 :maxx 10,
                     :ymin -30 :maxy 30
                     :height 500 :width 500)
	     (add-points analemma-data))))

Plotting Sine and Cosine


(spit "sin-cos.svg"
      (emit-svg
        (let [x (range -5 5 0.05)
              y1 (map #(Math/cos %) x)
              y2 (map #(Math/sin %) x)]
          (-> (xy-plot :minx -5 :xmax 5 :ymin -1.5 :maxy 1.5)
              (add-points [x y1] :transpose-data?? true)
              (add-points [x y2] :transpose-data?? true
                          :color (rgb 255 0 0))))))

Creating the Analemma logo

(emit
  (svg
    (apply group
           (rect 0 0 160 500 :fill "#ffffff")
           (-> (text {:x 120 :y 60} "Analemma")
               (style :fill #"000066"
                      :font-family "Garamond"
                      :font-size "75px"
                      :alignment-baseline :middle))
           (for [[x y] analemma-data]
             (circle (translate-value x -30 5 0 125)
                     (translate-value y -25 30 125 0)
                     2 :fill "#000066")))))

See the Analemma website for more examples.

Copyright © 2011 David Edgar Liebke

Distributed under the Eclipse Public License, the same as Clojure.

Something went wrong with that request. Please try again.