interval-mapping-schema-tutorial

How to create a schema for the interval-mapping tutorial.

First we define the area, a quiet width ratio:

let () =
  let svg = Svg.new_svg_document ~width:480 ~height:180 () in

  Svg.finish_svg svg;
  Svg.print_svg_document svg;
;;

We define a white background, and place two lines:

let () =
  let svg = Svg.new_svg_document ~width:480 ~height:180 () in

  Svg.add_rect svg
    ~x:0 ~y:0
    ~width:480
    ~height:180
    ~fill:"#fff"
    ~stroke:"#000"
    ~stroke_width:2.0
   ()
   ;

  Svg.add_line svg
    ~x1:45   ~y1:45
    ~x2:410  ~y2:45
    ~stroke:"#000"
    ~stroke_width:1.0
   ()
   ;

  Svg.add_line svg
    ~x1:45   ~y1:135
    ~x2:370  ~y2:135
    ~stroke:"#000"
    ~stroke_width:1.0
   ()
   ;

  Svg.finish_svg svg;
  Svg.print_svg_document svg;
;;

Here what we get:

We then plase a first line on the left:

  Svg.add_line svg
    ~x1:45   ~y1:45
    ~x2:45   ~y2:135
    ~stroke:"#000"
    ~stroke_width:1.0
   ()
   ;

based on the left points of the two vertical lines.

Then we move by five, to create an intersection:

  Svg.add_line svg
    ~x1:50   ~y1:40
    ~x2:50   ~y2:140
    ~stroke:"#000"
    ~stroke_width:1.0
   ()
   ;

If we zoom at the intersection w/ gimp:

we think that maybe we need to add a full opacity, maybe they changed the default, for the opacity?

    ~stroke_opacity:1.0

But: No! This is because the coordinates are grid alined!

I thought it will point the middle of the pixel.

Then we switch to the Float. module, to have the float equivalent of add_line.

intmapf.ml

But then we realize, the initial result was not that bad.

We can now just add the circles:

  Svg.add_circle svg
    ~cx:120.0
    ~cy:45.0
    ~r:5.6
    ~fill:"none"
    ~stroke:"#000"
    ~stroke_width:1.5
   ()
   ;

Here is the result.