How to Show Clusters in a Scatterplot

From Q
Jump to navigation Jump to search

This page describes how to display data from a k-means cluster analysis as a scatterplot, with the data points colored according to the clusters that have been identified.

In this basic example, there are only two input variables to the cluster analysis, and the clusters are obvious. In other examples, you may have several variables and want to plot two of the key variables of interest.


To create a scatterplot like this in Q you can:

  1. Create your k-means cluster analysis using Create > Segments > K-Means Cluster Analysis.
  2. Save a variable containing the cluster membership by selecting Create > Segments > Save Variable(s) > Cluster Membership.
  3. Add a scatterplot to your project using Create > Charts > Visualization > Scatterplot.
  4. In the Inputs section of the Object Inspector:
    • X coordinates: Choose the first variable you want to plot.
    • Y coordinates: Choose the second variable you want to plot.
    • Colors: Choose the variable which contains your cluster memeberships.
  5. Tick Automatic.

The options you choose should look a bit like this: