I spent a while this week creating an interactive viz of my favourite paper from my PhD. This threw up a few small issues that I hadn’t come across before. They don’t really merit a full blog post each, but they really made a difference to my viz, and I’m sure they’ll come up quite often with different datasets.
[quick explanation to contextualise the data: I measured Dutch people’s brain activity while they were tested on Japanese words they had just learned, either with their real or opposite Dutch translations. These are called event-related potentials, or ERPs, and they show amplitude of electrical activity over time. The differences in the brain data correlated with their scores in a separate two-alternative forced choice (2AFC) task where they had to guess the meanings of Japanese words; the better people were at guessing the meanings in the guessing task, the bigger the difference in brain activity during the testing task. I wrote a blog full of MS Paint drawings about that (and my PhD research in general) here]
Colour-coding a line: convert to ATTRIBUTE
In one of the graphs, I plotted a difference wave, which is the amplitude at each time point in the real condition minus the amplitude at each time point in the opposite condition. I wanted to colour-code this line by whether or not the effect was significant at that time point (which was 320ms – 796ms from the tests I did in Matlab and R). So, I plotted the line, dragged my calculated field onto the colour… and got this:
The line changed colour all right, but also created a path between the two non-significant parts. To get around this, the calculated field has to be set as an attribute, rather than a dimension:
Shading between two lines
One viz option that I didn’t go for in the end was to plot the two ERPs and then shade the gap between them according to the significance of the time window:
To do this, the data has to be in long form (i.e. one column for amplitude, one column to say which condition the amplitude is in; not one column for real and one column for opposite).
This is a dual axis viz with the amplitude as lines and then gantt bars (my new favourite mark type) with variable sizes. First, I dragged in measurement and added condition to the detail shelf to get two ERP lines for the two conditions. Then, I created some calculated fields; the average measurements for each condition separately, and then another calculated field to find the difference between those two (these are the same calculations as in the first point). As I calculated the difference using real minus opposite, I dragged the opposite average into the view, and made it into gantt bars. This created a lot of lines which were the same thickness, but I wanted the thickness of the bars to match the space between the two lines. Calculating the difference and putting this onto the size shelf does this:
All you have to do then is make it dual axis, synchronise axes, and manually fix the width of the gantt bars.
Two graphs, one filter
In my final dashboard, I had one graph of the general ERPs for each condition, and another graph of the difference waves (both for individual participants and overall). In each worksheet, I had used the participants’ score in the guessing game task to filter the brain data. When I dragged the two worksheets into a dashboard, both filters showed up, and both filters acted independently:
Since they’re using the same measure to filter the data, it would be much nicer if one filter applied to both graphs on the dashboard. To do this, simply go back to one of the worksheets, right click on the filter, and click on Apply to Worksheets:
The default is set to Only This Worksheet, but instead, we want this filter to filter the data on the other worksheet as well. Click Selected Worksheets, and you’ll see this box:
Click on the worksheets you want the filter to work on, and that’s it. Now you can drag both worksheets into the dashboard again, and the filter from the difference wave sheet won’t appear again because the dashboard knows that the filter from the grand average sheet already applies to it:
These are really simple things, but they made my viz a whole lot better.