Scatter plots

A scatter plot can be generated by using the `scatterplot function:

    `scatterplot data,width,height;
       

The data parameter is a set of tuples of the following type:

    {[$:series, &:xValue, &:yValue]}
       

where series is the name of the series to which a given data point belongs, and xValue and yValue are the values in the data point. For example, the following Rax program:

    %include "SimpleCharts.rax";

    // Just define some labels.
    //
    {$}: labs := {"aap", "noot", "mies", "jet", "teun", "gijs", "vuur"};

    // Get a random string form an set of strings.
    //
    $<-{$}: rndlab <- { out := in(1 + ?#? % (#in)); };

    // Generate some random data
    //
    {[$:series, &:x, &:y]} : data :=
      project[rndlab(labs), (&)(21 + .#1 % 280), (&)(1 + ?#? %
      200)] {1..500}
      \/
      project["lam", (&)(20 + .#1),(?#? % 100) +
      sin:(((&).#1)/200*2*M_PI) * 90 + 100] {1..280}
      \/
      project["wim", (&)(20 + .#1), (?#? % 100) +
      sin:(((&).#1)/200*2*M_PI) * 90 + 100] {1..280}
      \/
      project["zus", (&)(20 + .#1), (?#? % 100) +
      sin:(((&).#1)/200*2*M_PI) * 90 + 100] {1..280};

    `scatterplot data, 1000.0, 1000.0;
       

Will produce the chart in Figure 16.2, “A scatter plot generated by Rax”. Tip: zoom in on the scatter plot :-).

Figure 16.2. A scatter plot generated by Rax