 
     (let [vecs
           (for [c (range cols) r (range rows)]
-                 (let [num (or (::core/density-at-last-update (get grid-cells [r c]))
-                               0.0)]
-                   num
-                   ))]
-      (->>
-        vecs
-        (viz/matrix-2d rows cols)
-        ))
-
+            (let [num (or (::core/density-at-last-update (get grid-cells [r c]))
+                          0.0)]
+              num
+              ))]
+      {:matrix (->>
+                 vecs
+                 (viz/matrix-2d rows cols)
+                 )
+       :rows   rows
+       :cols   cols})
     ))
 
 (defn heatmap-spec
   [id the-matrix]
+  (println "id, matrix: " id the-matrix)
   {:matrix        the-matrix
    :value-domain  (viz/value-domain-bounds the-matrix)
    :palette       (->> id (grad/cosine-schemes) (apply grad/cosine-gradient 100))

   :layout        viz/svg-heatmap})

(defn cartesian-viz
  [prefix id the-matrix & [opts]]
  (clojure.pprint/pprint the-matrix)
  (->> {:x-axis (viz/linear-axis
                  {:domain [0 50]
                   :range  [50 550]
                   :major  10
                   :minor  5
                   :pos    280})
        :y-axis (viz/linear-axis
                  {:domain      [0 10]
                   :range       [280 20]
                   :major       1
                   :pos         50
                   :label-dist  15
                   :label-style {:text-anchor "end"}})

              _            (println "tsne: " algo-name)
              output-map   {algo-name (tsne/tsne input-matrix 2 :tsne-algorithm algo-name :perplexity 0.01)}]
          output-map)))
  (let [hm1 (grids-2d->heatmap-vec grid-cells props)
        hm2 (grids-2d->heatmap-vec grid-cells props)]

    (cartesian-viz "hm" :rainbow2 (:matrix hm1) (:cols hm1) (:rows hm1))
    (cartesian-viz "hm" :orange-blue (:matrix hm2) (:cols hm2) (:rows hm2)))
  )


