     :dash-astar-nos      [da 17 "DAcH-A*"]
     :dash-astar-nods     [da 18 "DAxH-A*"]}))
 
+(defn alg-title [a] (-> alg-styles a (nth 2)))
+(defn alg-style [a]
+  (let [[t c] (alg-styles a)]
+    {:lw 3 :lt t :pt t :lc c}))
+
+(def chart-dir "/Users/w01fe/Projects/phdthesis/graphs/")
+
+(defn make-chart [ds algs field & [more-chart-opts derive pdf-file]]
+  (util/assert-is (empty? (remove ds algs)))
+  (let [sks (map alg-title algs)]
+    (-> (smart-results->dataset
+         (select-keys ds algs)
+         (or derive
+             (if (= field :secs)
+               (derive-median :secs :ms #(/ % 1000))
+               (derive-median field field))))
+        (datasets/ds->chart
+         [:alg] :size field
+         (merge chart-opts more-chart-opts)
+         (comp alg-style keyword first)
+         (comp alg-title keyword first)
+         (fn [arg] (sort-by #(util/position (:title %) sks) arg)))
+        (#(if pdf-file (charts/plot % (str chart-dir pdf-file)) (charts/plot %))))))
+
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  Nav charts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (def ns-results
   (->> (str experiments/*default-run-dir* "thesis-ns2/")
        (experiments/read-smart-results (make-ns-exps) )
+       (util/map-keys keyword)
        delay))
 
 ;; Skip: explicit-ah-astar explicit-dash-astar

                                   (filter :ms s)))]
      {target-field r})))

(let [fl 1 bb 2 sa 3 na 4 ah 5 ex 6 da 7]
 (def alg-styles
   {:dijkstra            [fl 1  "UCS"]

(def ns-fast-algs [:dash-astar-nods :astar :dash-astar-first :dash-astar  :dash-astar-hoc :dash-astar-nos 
                   :full-ah-astar :dash-astar-ldfs])



(defn make-ns-charts []
  (doseq [[t ks opts]
          [["slower" ns-slow-algs {:xrange "[5:500]" :yrange "[0:50]"}]
           ["faster" ns-fast-algs {:xrange "[5:500]" :yrange "[0:12]"}]]]
    (make-chart
     @ns-results ks :secs
     (assoc opts
       :title (str "random nav-switch problems - " t " algorithms")
       :xlabel "grid size (side length)" :ylabel "runtime (s)"))))

(defn make-ns-charts []
  (let [opts (fn [t yr]
               {:title (str "random nav-switch problems - " t " algorithms")
                :xlabel "grid size (side length)" :ylabel "runtime (s)"
                :xrange "[5:500]" :yrange yr})]
    (make-chart @ns-results ns-slow-algs :secs (opts "slower" "[0:50]"))
    (make-chart @ns-results ns-fast-algs :secs (opts "faster" "[0:12]"))))


; (def ns-res (experiments/read-smart-results (make-ns-exps) (str experiments/*default-run-dir* "thesis-ns/")))
