I'm trying to plot 6 selected pair subplots with the combination of facetgrid of seaborn and scatter plot from matplotlib. I'm getting plot, but subplots remains empty whereas facetgrid gets plotted in a new figure.
Below is my code-
pairs = [["SepalLengthCm", "SepalWidthCm"], ["PetalLengthCm", "PetalWidthCm"], ["SepalLengthCm", "PetalWidthCm"], ["PetalLengthCm", "SepalWidthCm"], ["PetalLengthCm", "SepalLengthCm"], ["PetalWidthCm", "SepalWidthCm"]]
plt.figure(figsize=(15,8))
i = 1
for each in pairs:
plt.subplot(2,3,i)
sns.set_style("whitegrid")
fg = sns.FacetGrid(iris, hue="Species", size=4)
fg.map(plt.scatter,each[0], each[1]).add_legend();
plt.show()
i += 1
Sample Output:
Can someone help out with it?
