                                     node-2 (:dest edge)]
                                 {:x1 (* layer-sep (:layer-id node-1))
                                  :x2 (* layer-sep (:layer-id node-2))
-                                 :y1 (get n-ys node-1)
-                                 :y2 (get n-ys node-2)}))
-                            (reduce set/union (vals (succs flat-graph))))]
-             {:nodes nodes :edges edges}))
-         node-ys)))
+                                 :y1 (get node-ys node-1)
+                                 :y2 (get node-ys node-2)}))
+                            (reduce set/union (vals (succs flat-graph))))
+                 ;; min-x is always 0 for these debug graphs
+                 mn-x 0
+                 mx-x (* layer-sep (dec (count layers)))
+                 mn-y (min-y class-graph node-sep char-sep)
+                 mx-y (max-y class-graph node-sep char-sep)
+                 ;; _ (println mn-x mx-x mn-y mx-y)
+                 vbox (s/join " " [(- mn-x 50) (- mn-y 50) (+ 100 (- mx-x mn-x)) (+ 100 (- mx-y mn-y))])]
+             {:nodes nodes :edges edges :vbox vbox}))
+         class-graphs)))
 
 
 (defn draw-d3-coarse!
   [plot-data]
   (doall (map
           (fn [p-data]
-            (let [svg (-> js/d3 (.select "#app") (.append "svg") (.attr "viewBox" "-50 0 4000 1000"))]
+            (let [svg (-> js/d3 (.select "#app") (.append "svg") (.attr "viewBox" (:vbox p-data))
+                          (.attr "preserveAspectRatio" "xMidYMid meet"))]
               (-> svg
                   (.selectAll "path")
                   (.data (clj->js (:edges p-data)))

            [fatlip.protocols :refer [nodes succs Node]]
            [fatlip.sparse :refer [input->SparseGraph]]
            [fatlip.order :refer [SparseGraph->FlatGraph]]
            [fatlip.plot :refer [FlatGraph->ClassGraphs ys pathify plot-xs]]
            [fatlip.draw.d3 :refer [data->path]]))


(defn plot-alignments
  [flat-graph max-slope min-arc-radius layer-sep node-sep char-sep]
  (let [{:keys [layers characters]} flat-graph]
    (->> flat-graph

         (map #(plot-xs % layers max-slope layer-sep)))))


#_(defn input->plots
  [input & {:keys [max-slope min-arc-radius layer-sep node-sep char-sep]
            :or {max-slope 10
                 min-arc-radius 15
