Use the pairs function to draw a scatterplot matrix in R.
pairs(iris[1:4], main = "Edgar Anderson's Iris Data", pch = 21, bg = c("red", "green3", "blue")[unclass(iris$Species)])
I tried to draw this with python, but it seems that the familiar matplotlib does not implement a function to draw a scatterplot matrix.
You can implement it by making full use of subplot, but here, draw a scatter plot matrix using a graph drawing library called seaborn. I will show you how.
Dependency matplotlib (>=1.4) seaborn (>=0.5) Both should be installable with pip.
import matplotlib.pyplot as plt
import seaborn as sns
df = sns.load_dataset("iris")
sns.pairplot(df, hue="species", size=2.5)
plt.show()
seaborn has other tools for drawing various cool graphs. If you are tired of matplotlib graphs, please use it.
Recommended Posts