Repository: milliams/plotlib (language: rust)

Issue:
Y axis label overlaps with tick labels
![screenshot](https://i.imgur.com/FfVUP6S.png)


Discussion / hints:

Fix patch:
diff --git a/src/page.rs b/src/page.rs
index dff6293..7835821 100644
--- a/src/page.rs
+++ b/src/page.rs
@@ -62,7 +62,7 @@ impl<'a> Page<'a> {
         let (width, height) = self.dimensions;
         let mut document = Document::new().set("viewBox", (0, 0, width, height));
 
-        let x_margin = 80;
+        let x_margin = 90; // should actually depend on y-axis label font size
         let y_margin = 60;
         let x_offset = 0.6 * f64::from(x_margin);
         let y_offset = 0.6 * f64::from(y_margin);
diff --git a/src/svg_render.rs b/src/svg_render.rs
index 56dce31..d7770a9 100644
--- a/src/svg_render.rs
+++ b/src/svg_render.rs
@@ -87,6 +87,8 @@ pub fn draw_y_axis(a: &axis::ContinuousAxis, face_height: f64) -> node::element:
     let mut ticks = node::element::Group::new();
     let mut labels = node::element::Group::new();
 
+    let y_tick_font_size = 12;
+
     for &tick in a.ticks().iter() {
         let tick_pos = value_to_face_offset(tick, a, face_height);
         let tick_mark = node::element::Line::new()
@@ -103,19 +105,21 @@ pub fn draw_y_axis(a: &axis::ContinuousAxis, face_height: f64) -> node::element:
             .set("y", -tick_pos)
             .set("text-anchor", "end")
             .set("dominant-baseline", "middle")
-            .set("font-size", 12)
+            .set("font-size", y_tick_font_size)
             .add(node::Text::new(tick.to_string()));
         labels.append(tick_label);
     }
 
+    let y_label_offset = -(face_height / 2.);
+    let y_label_font_size = 12;
     let label = node::element::Text::new()
         .set("x", -30)
-        .set("y", -(face_height / 2.))
+        .set("y", y_label_offset - f64::from(y_label_font_size))
         .set("text-anchor", "middle")
-        .set("font-size", 12)
+        .set("font-size", y_label_font_size)
         .set(
             "transform",
-            format!("rotate(-90 {} {})", -30, -(face_height / 2.)),
+            format!("rotate(-90 {} {})", -30, y_label_offset),
         )
         .add(node::Text::new(a.get_label()));
 


Test patch: