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.
A cluster membership variable from a K-Means Cluster analysis.
To create a scatterplot like this in Displayr you can:
- Create your k-means cluster analysis using Anything > Advanced Analysis > Cluster > K-Means Cluster Analysis.
- Save a variable containing the cluster membership by selecting Anything > Advanced Analysis > Cluster > Save Variable(s) > Cluster Membership.
- Add a scatterplot to your project using Visualization > Scatter > Scatter.
- 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.
The options you choose should look a bit like this: