Best-fit lines

The code below is the source for this graph.

<?php
// Best-fit lines
require_once 'SVGGraph/autoloader.php';

$colours = ['#e11', '#1b1', '#11e', '#888'];

$settings = [
  'auto_fit' => true,
  'show_tooltips' => false,
  'back_stroke_width' => 0,
  'axis_max_h' => 20,
  'grid_division_v' => 10,
  'marker_size' => 4,
  'marker_type' => 'cross',
  'grid_back_colour' => '#f9f9f9',
  'pad_left' => 5,
  'pad_top' => 5,
  'pad_right' => 5,
  'pad_bottom' => 5,
  'structured_data' => true,
  'best_fit' => 'straight',
  'best_fit_colour' => $colours,
  'best_fit_range' => [ [ NULL, NULL], [1, 6], [0, 9] ],
  'best_fit_project' => 'both',
  'best_fit_project_opacity' => 0.5,
  'grid_back_stripe' => true,
  'grid_back_stripe_colour' => '#fff',
  'shape' => [
    'rect', 'x' => 'g1', 'y' => 'gt', 'width' => 'u5', 'height' => 'gh',
    'fill' => '#8c8', 'stroke' => 'none', 'opacity' => 0.2, 
  ],
];

$type = 'MultiScatterGraph';
$values = [];
srand(100);
for($i = 2; $i < 12; ++$i) {
  for($c = 1; $c < 5; ++$c) {
    $val = [$i + 0.05 * (rand(1, 100) - 50)];
    $val[$c] = $c + 0.95 * rand($c, 100);
    $values[] = $val;
  }
}

$graph = new Goat1000\SVGGraph\SVGGraph(600, 200, $settings);
$graph->colours($colours);
$graph->values($values);

$graph->render($type);

Please note: the source code above comes from a script used to generate one of the example graphs on the site. This is simply a wrapper page to apply highlighting and make the source code easier to read, so there is no content here to describe what the source code is doing.