1

I want to set a figure size for each subplot. One size is fine for all. Data is from a pandas dataframe

X = pd.DataFrame(model_data[:,1:], columns = col[0:12])
y = pd.DataFrame(model_data[:,0], columns = ['mv'])


a = 1
for i in range(12):
    plt.figure(figsize=(20, 8))
    plt.subplot(3,4,a)
    plt.scatter(X.iloc[:, i], y)
    a += 1

I want all the plots to be in 3x4 format with each sized at 20, 8.

How do I efficiently solve this problem?

Emma
  • 27,428
  • 11
  • 44
  • 69
Py_Student
  • 163
  • 1
  • 12

1 Answers1

1

The subplots will be the same size by default. (20,8) is pretty big for each subplot. Perhaps start with (20,8) for the entire figure size to start:

fig, axes = plt.subplots(3, 4, figsize=(20,8))
for i, ax in enumerate(axes.flatten()):
    ax.scatter(X.iloc[:, i], y)
seanswe
  • 311
  • 2
  • 7