0

Right now I have four different regplots I want to show, however, they all appear to be combined under 1 plot. Please help me separate them into 4 distinct plots.

sns.regplot(x = df["Rank"].head(100), y = df["Assets"].head(100))

sns.regplot(x = df["Rank"].head(100), y = df["Market Value"].head(100))

sns.regplot(x = df["Rank"].head(100), y = df["Sales"].head(100))

sns.regplot(x = df["Rank"].head(100), y = df["Profit"].head(100))
subspring
  • 690
  • 2
  • 7
  • 23
  • Does this solve your problem? https://stackoverflow.com/questions/38082602/plotting-multiple-different-plots-in-one-figure-using-seaborn – nonDucor Mar 08 '22 at 09:54

2 Answers2

1

Try the following:

import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd

data = {'Rank': [3, 2, 1, 0], 'Assets': [1, 2, 3, 4], 'Market Value': [5, 6, 7, 8], 'Sales': [9, 10, 11, 12], 'Profit': [13, 14, 15, 16]}

df = pd.DataFrame.from_dict(data)


fig, axs = plt.subplots(ncols=4, figsize=(16,3))

sns.regplot(x = df["Rank"].head(4), y = df["Assets"].head(4), ax=axs[0])
sns.regplot(x = df["Rank"].head(4), y = df["Market Value"].head(4), ax=axs[1])
sns.regplot(x = df["Rank"].head(4), y = df["Sales"].head(4), ax=axs[2])
sns.regplot(x = df["Rank"].head(4), y = df["Profit"].head(4), ax=axs[3])

enter image description here

gremur
  • 1,645
  • 2
  • 7
  • 20
0

You could also add

plt.show()

after each line.

Kilian
  • 468
  • 2
  • 9