How to Show Clusters in a Scatterplot
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:
- Create your k-means cluster analysis using Create > Segments > K-Means Cluster Analysis.
- Save a variable containing the cluster membership by selecting Create > Segments > Save Variable(s) > Membership.
- Add a scatterplot to your project using Create > Charts > Visualization > Scatterplot.
- 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.
- Tick Automatic.
The options you choose should look a bit like this: