I have a bunch of x and y coordinates of different points and the cluster it belongs to. How do I plot the clusters? Here's a sample of what I'm working with:
x-values y-values cluster
3 5 0
2 3 1
1 4 0
8 3 0
2 2 2
7 7 2
How do I plot a scatterplot of the points as a '*' or '+' and color shade the clusters so that it looks like:
Note I'm not doing a PCA analysis.
Following may be useful:
library(ggplot2)
ggplot(ddf, aes(x.values, y.values, color=factor(cluster)))+geom_point()
Cluster areas can be seen with stat_ellipse(). They are not seen with this data due to following errors:
ggplot(ddf, aes(x.values, y.values, color=factor(cluster)))+geom_point()+stat_ellipse()
Too few points to calculate an ellipse
Too few points to calculate an ellipse
Too few points to calculate an ellipse
geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
It will show better if points are well clustered as in a similar plot using iris data:
ggplot(iris, aes(Sepal.Length, Petal.Length, color=Species))+geom_point()+stat_ellipse()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With