8
$\begingroup$

I have a large set of country data that is crowded (as you can see below), but I need the labels and the outliers – I also have a lot of graphs, so it would be tedious to reset the window and add in false datapoint for the outliers.

Is there a good alternative to a scatterplot that might be better in such a situation? I would really like to do a map, but I need both parts of the ordered pair shown.

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ This strikes me as hard to answer in its present form. Can you provide more information about your situation, your data, & your goals? What are the variables? Do you just need to identify the outliers somehow (eg, would a non-visualization-based approach be OK)? What software are you using? Are you just asking for code? (If so, the question would be off-topic here.) Etc. $\endgroup$ Jan 14, 2015 at 20:33
  • $\begingroup$ There are software (in R, I think) that will try to place labels so they do not overplot. Also, if you have all the labels you do not need the points, the label will do the job! Try with smaller font size, and even maybe with fonts which can be seen through, dont remember the name, should be possible in R, by varying the transparency. Have a look at ggplot2, or F Harrells Design, maybe something in there. $\endgroup$ Jan 14, 2015 at 21:07

2 Answers 2

13
$\begingroup$

A couple techniques are demonstrated in this plot I made a few months ago.

  1. Only label the "interesting" points, and rely on a hover label for identifying other points on demand. This requires human intervention to do well, though software can come close with heuristics such as only showing labels when they can be shown without overlap.

  2. Transform the scale, such as with logs or quantiles. The caution here is that the scale is no longer directly aligned with our perception. The viewer has to keep the transformation in mind.

enter image description here

Other options:

  1. Use trellising or small multiples. That is, show a series of graphs, each with a subset of the points, such as one graph for each region for your country data.

  2. Use linked single-variable charts, such as bars or dot plots, so that the label is in the axis. It helps if you can sort by either variable interactively.

enter image description here

$\endgroup$
5
  • $\begingroup$ I love the plot at the top; did you release the code for it somewhere? "That is, show a series of graphs, each with a subset of the points, such as one graph for each region for your country data" is a good point - Nick Cox has an excellent answer somewhere, showing how this can be done in Stata (I think he wrote a package for it). I will see if I can track it down and link it. $\endgroup$
    – Silverfish
    Jan 15, 2015 at 2:06
  • $\begingroup$ Thanks @Silverfish! I made the scatter plot interactively in JMP (my company's product) with the labels hand-tuned and the pink parts added programmatically. Perils of "publishing" to Twitter -- I need to post it somewhere with a bit more explanation, data and scripts. Will follow up with a link here if I succeed. $\endgroup$
    – xan
    Jan 15, 2015 at 2:22
  • 1
    $\begingroup$ @Silverfish You may be thinking of posts on Statalist, e.g. statalist.org/forums/forum/general-stata-discussion/general/… $\endgroup$
    – Nick Cox
    Jan 15, 2015 at 17:00
  • 1
    $\begingroup$ The data and scripts for my first graph are at community.jmp.com/docs/DOC-7108. $\endgroup$
    – xan
    Jan 16, 2015 at 13:51
  • $\begingroup$ @Nick Cox That's right! Well actually I think I saw it in: Cox, N.J. 2010, "Graphing subsets", The Stata Journal, 10: 670-681. But the colour graphics in that Statalist post actually make it even clearer. Link to the journal article is www.stata-journal.com/sjpdf.html?articlenum=gr0046 (I suspect the question mark is stopping it appearing as a hyperlink) $\endgroup$
    – Silverfish
    Jan 16, 2015 at 15:15
5
$\begingroup$

If you want an alternative to a scatter plot, then a parallel coordinates plot may work, particularly if you are trying to show the relationship between many variables. You "have a lot of graphs", and a parallel coordinates plot might be able to reduce that down to one! Here's an example on the famous Iris data set, taken from Wikipedia (image credit):

Parallel coordinate plot for iris data

The plot shows variation between species very clearly. You might choose to colour by geographic region or level of development instead. We can see how hard it is to distinguish the three species based on sepal width, but there is more separation in their petal lengths. After a bit of mental adjustment (our eyes can be too trained to look for an "upward slope"), there is obviously a positive correlation between petal width and petal length because higher petal widths are associated with higher petal lengths. Flowers at the top of the scale for one, tend to be at the top of the scale for the other - this is manifested in roughly parallel lines running between the axes. On the other hand there is a negative correlation between sepal width and sepal length, because plants with a high sepal width tend to move down to having a low sepal length and vice versa (we see diagonal lines crossing over).

The image manages to capture much of the information available in a whole matrix of scatter plots (image credit):

Scatter matrix for iris data

On the positive side, the parallel axis plot gives us the ability to follow an individual across all measured variables: if we see two interesting points on two separate scatterplots, particularly outliers, it may not be evident whether they represent the same individual, but on a parallel axis plot we can just "follow the thread". On the downside, ditching all those scatter plots throws away information about multivariate relationships. Most obviously, we can't see some details of the clustering so clearly (though note Nick Cox recommends parallel coordinate plots for the purpose of investigating how "deep" clustering goes through the variables) and possibilities for linear discrimination are completely obscured. Also, it can get hard to see correlations between axes which are far apart on the parallel coordinates plot, which would be more evident in a scatter matrix.

If you have the option of interactivity, rather than a static visualization, then parallel coordinate plots offer you some options to get around this. For example, a user can switch the order of the axes, putting variables next to each other to see the relationship of interest more clearly. Because positive and negative correlation behave so differently on a parallel coordinates plot, it's helpful to be able to flip an axis (if you reverse the direction of an axis which has negative correlation with an adjacent axis, then the lines between them get "untangled"). Even on a static plot, it's most effective to reverse axes to produce as many positive correlations as possible, and order axes so as to make consecutive correlations as strong as possible, since it's hard to follow a strand through a tangle (see Nick Cox on this point).

Perhaps the most important interactive feature is brushing and linking: the user can select e.g. the upper quartile of individuals based on one variable, and their lines are automatically highlighted all the way through the plot. If on another axis, points mostly around the top are highlighted, then this suggests positive correlation (but we ought to check to see the lower quartile is associated with points around the bottom of the second variable); if points mostly around the bottom are highlighted, it suggests negative correlation; if a selection of points randomly scattered all the way up the axis are highlighted, it suggests little correlation.

With the number of countries you're including, it seems difficult to label them all on any plot unless you have unusually generous space constraints. You may have to settle for highlighting only the most important individual countries. On an interactive visualization, hover labels can avoid clutter (as @xan points out) and perhaps you could allow users to highlight all countries in a given region (or some other grouping) which might automatically display their labels.

If you only use a limited number of labels, one place you might consider putting them is on the axes themselves. If you look at Edward Tufte's The Visual Display of Quantitative Information, Chapter 7: Multifunctioning Graphical Elements, you'll see this closely resembles Tufte's suggestion for what he called a "table-graphic" for government tax receipts (it may be more familiar to you as a "slopegraph"). Each axis becomes a sort of ranking table, which is a nice feature. (There are some differences between the approaches, particularly since Tufte's example table-graphic used the same units and scale on each axis, rather than normalizing the data to fit on, and since his "axes" represented an earlier and later time period, the slopes had an additional interpretation as a rate of growth. Those interpretations will not generally hold for a parallel coordinates plot, but the idea of a ranking table on each axis does.)

Links and references

$\endgroup$
2
  • 1
    $\begingroup$ +1. Thanks for the mention. Note that combining red and green creates a challenge for many people, especially when the symbol is the same! Red, blue and black would work better. $\endgroup$
    – Nick Cox
    Jan 15, 2015 at 16:58
  • $\begingroup$ @Nick Yes I thought these were not very good example plots on that front - I only borrowed them because they're freely licensed (on Wikipedia). If I can find better freely licensed examples I'd replace them (or if I've got a bit of time to make my own). $\endgroup$
    – Silverfish
    Jan 15, 2015 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.