Home > Software design >  How to make a Scatter Plot for a Dataset with 4 Attribtues and 5th attribute being the Cluster
How to make a Scatter Plot for a Dataset with 4 Attribtues and 5th attribute being the Cluster

Time:11-17

I have a dataset which looks like this,

enter image description here

It has four attributes and the fifth column (which I added by myself) is the cluster of each row to which the row belongs.

I want to build something like a Scatter Plot for this dataset, but I am unable to do so. I have tried searching it up and the best I could find was this following question on Stackoverflow,

How to make a 4d plot with matplotlib using arbitrary data

Using this, I was able to make a Scatter Plot but it can only be done for three attributes while fourth attribute being the cluster of each row.

Can anyone help me figure out how would it be possible to do the same to make a Scatter Plot for a dataset similar to mine?

CodePudding user response:

I would recommend something like seaborn's pairplot:

import seaborn as sns

sns.pairplot(df, hue="cluster")

See the images in the link, of what it looks like. This creates several pairwise scatterplots instead of trying to make a 3D plot and arbitrarily flatten one of the dimensions.

  • Related