This article 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.
.
Requirements
A cluster membership variable from a K-Means Cluster analysis.
Method
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) > Cluster 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 memberships.
- Tick Automatic.
The options you choose should look a bit like this:
NEXT