Snake plot is the term used to describe a line chart on its side. So rather than the lines running left-right (x-axis) they run up-down (y-axis).
The image below is an example of a snake chart, created in PowerPoint.
A snake chart is not really a line chart – it’s a scatterplot with lines connecting the points in each series (which happen to run vertically).
There are 3 methods for creating a snake chart and exporting it to PowerPoint.
1. Making a snake plot in Q using its built-in chart type and exporting it to PowerPoint as an image
In Q, creating a snake plot is as simple as turning a table into a chart with the push of a button. Simply create a crosstab, and then go to Show Data As: Tables > Snake Plot in the ribbon.
Q will then turn your table into a snake plot! The brown question (columns of the table) becomes the series (each line, or “snake”). The rows of the original table become the categories and the y-axis is labeled as such.
If you want to customize it, you can do this on the right-hand side with the Object Inspector. When you’re ready to export to PowerPoint, simply use the button in the ribbon. You can use this method to export to PowerPoint as an image.
2. Setting up a snake plot within PowerPoint as an Excel chart
Setting up a snake plot within PowerPoint without Q’s assistance is possible. They are technically Excel Charts within PowerPoint. Consider the data below, consisting of the spreadsheet within PowerPoint used to create both images of the snake plots above.
Notice that there is a column B which is numbered 6 to 1 in decreasing order. This is essential to the chart because it needs to reference these as points for the y-axis. So if you don’t have this in your source table, you’ll need to include it.
To turn this into a chart within PowerPoint, you need to have the chart type within PowerPoint set as an “X Y Scatterplot with Straight Lines and Markers”. Then the tricky bit is telling PowerPoint how to reference this information (using Chart Options > Design > Select Data in PowerPoint). I find it’s often easier to start from scratch with this (i.e. remove all the legend entries and start afresh with the window below).
Then, you need to Add in each series to the box on the left. With each, you set up the references cell/arrays, as per the below:
You’ll need to repeat this for each series. In the above example I had three.
Then you design the chart within PowerPoint as appropriate (using the chart tools). The major drawback of doing this in PowerPoint, is that you can’t specify the y-axis labels (i.e. column A in that data table above). Researchers get around this by inserting a table into PowerPoint to sit adjacent/underneath the snake plot which contains the labels.
3. Use an R Output to help automate the updating
In the example above, we created the snake plot in PowerPoint and needed Column B (which is an array of integers in descending order). This is something you would need to insert manually into the PowerPoint data source.
If you’re using Q, you can write an R Output that does this for you. This can give you the ability to update the Excel Chart automatically into PowerPoint from Q.
Suppose you set up a table as per the example above – the average number of colas consumed (rows) by segment (columns). Let’s say it had a reference name of
sourcetab (right click on table and select 'reference name'). If you wanted to make a table that’s in the right format for PowerPoint, you could augment the table by using an R Output (Create > R Output). The code for the R Output would be as follows:
data = sourcetab
yaxis = nrow(data):1
export_table = cbind(yaxis,data)
This creates a table (as an R Output) as per the following:
The second line of the code creates an array that is equal to the number of rows in the source table working backwards to 1 an integer at a time. If you’d written
6:1, it would be an array of
1:6 would be an array of
Once you export this to PowerPoint, as an XY Scatterplot, you still need to go through the manual setup process as per the previous section of this article. The benefit of doing it this way is that if your data changes (in Q), you can automatically update the table, and therewith the plot, in PowerPoint.
The fourth line in the code is optional but is used to specify the number of columns to be exported. It is a safeguard in case an additional column is added to the table. In this case, only the first 4 columns (including y-axis) will be shown.