Chapter 16. Plotting

Table of Contents

Bar plots
Scatter plots

In a data-analysis system like Rax, the most important use of the graphical procedures will be visualizing the data. To make it easy, the standard Rax distribution contains a plotting library with various chart types. To use the plotting library, include it in your script:

    %include __EXE_PATH__ "rx_GraphicalEngine/SimpleCharts.rax";

Bar plots

A bar plot can be generated by using the `barplot function:

    `barplot data,width,height;

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

    {[$:series, $:category, &:value]}

where series is the name of the series to which a given data point belongs, category is the name of the category to which the data point belongs and value is the value in the data point. For example, the following Rax program:

    %include "SimpleCharts.rax";

    {[$:vehicleType, $:dayOfWeek, &:number]} : data := {
      ["cars", "Monday", 1.0],
      ["cars", "Tuesday", 3.0],
      ["cars", "Wednesday", 6.0],
      ["cars", "Thursday", 4.0],
      ["cars", "Friday", 9.0],
      ["suvs", "Monday", 4.0],
      ["suvs", "Tuesday", 4.0],
      ["suvs", "Wednesday", 6.0],
      ["suvs", "Thursday", 6.0],
      ["suvs", "Friday", 16.0],
      ["trucks", "Monday", 2.0],
      ["trucks", "Tuesday", 5.0],
      ["trucks", "Wednesday", 4.0],
      ["trucks", "Thursday", 5.0],
      ["trucks", "Friday", 12.0],

    `barplot data, 600.0, 400.0;

Will produce the chart in Figure 16.1, “A bar plot generated by Rax”.

Figure 16.1. A bar plot generated by Rax