rugplot: Heatmaps#

A heatmap is typically a rectangular tiling of a color-shaded data matrix. Additionally, this technique is one of the most space-efficient ways to visualize data. Here some examples are given to show how to create heatmaps using the rugplot container. The exergaming dataset from Soancatl-Aguilar et al. [SAvandGrondeL+17] will be used to create such examples. The dataset can be downloaded by running the following command

wget https://raw.githubusercontent.com/rijksuniversiteit-groningen/rugplot/master/tests/testthat/data/exergamelf2.csv

or by adding the link in the previous command to the JSON template that will be created in the second step to create the heatmap.

Creating a heatmap using the rugplot container#

For simplicity it is better to create an alias, see the Docker commands section.

  1. Step 1, create a rugplot histogram template

    rugplot template -p heatmap
    

    A heatmap_params.json file will be created including some of the name/value pairs listed below:

    {
        "description": "Parameters to create a heatmap plot using the 'rugplot' R package",
        "filename": "<filename path>",
        "method": "raster",
        "aesthetics": {
            "y_variable": "<Y required column name>",
            "x_variable": "<X required column name>",
            "fill": "<required variable>",
        },
    }
    
  2. Step 2, adding 'data file', 'x, y and fill variables', and some save properties:

    {
        "filename": "exergamelf2.csv",
        "aesthetics": {
            "y_variable": "myVars",
            "x_variable": "idrow",
            "fill": "normVal",
        },
        "save": {
            "save": true,
            "outputfilename": "exergaming_heatmap",
            "width": 17,
            "height": 7,
            "dpi": 300,
            "device": "png",
        }
    }
    
  3. Step 3, create the heatmap

    rugplot plot -p heatmap --file heatmap_params.json
    

    The result will be stored in the exergamin_heatmap.png file.

    heatmap
  4. Step 4, customizing color, label and LaTeX format

    LaTeX breaks#
    {
      "labels": {
          "x": "Trials per participant",
          "y": "Balance measures",
          "fill": "Normalized\nmeasures",
      },
      "colour_scales": {
          "fill_gradient": {
              "method": "gradient",
              "low": "#fee0d2",
              "high": "#67000d",
           }
      },
      "axes_scales": {
          "y_discrete": {
              "labels": ["medTIms51 = I`", "medTI51 = I",
              "medSpeed = Speed", "medLsdD51 = SD`",
              "medLsd51 = SD", "medLrmslD51 = RMS`",
              "medLrms51 = RMS", "medLcovD51 = CoV`",
              "medLcov51 = CoV", "medK = $\\\\kappa$",
              "meanK = $\\\\overline{\\\\kappa}$"]
          }
      },
      "save": {
          "device": "tikz",
          "sanitize": false
      }
    }
    
    heatmaptikz

References#

SAvandGrondeL+17

Venustiano Soancatl-Aguilar, Jasper J. van de Gronde, Claudine J. C. Lamoth, Mike van Diest, Natasha M. Maurits, and Jos B. T. M. Roerdink. Visual data exploration for balance quantification in real-time during exergaming. PLOS-One, January 2017. doi:10.1371/journal.pone.0170906.