3
$\begingroup$

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:

enter image description here

Can someone help out with it?

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.