0

I am working on making multiple distribution plots using matplotlib and seaborn library.

To be specific I try to put 16(= 4 x 4) plots in 1 figure.

The thing is x-axis label look cut off like as below.

enter image description here

How should i adrress this problem?

I wrote code as below.


array = aa_il.values

a = [0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3]
b = [0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3]

f, axes = plt.subplots(4, 4, figsize=(15, 10), sharex=False)

for each, i, j in zip(np.unique(array[:,7])[:20], a, b):
    sns.distplot(pd.DataFrame(array[array[:,7] == each,:]).rename(columns = {9 : each})[each].astype('int64'), color="blue", ax=axes[i, j])
    
user3685918
  • 335
  • 2
  • 12

2 Answers2

2

plt.tight_layout() should solve your problem.

karthik_ghorpade
  • 374
  • 1
  • 10
0

you can just change the figsize:

fig, ((ax0,ax1),(ax2,ax3))=plt.subplots(nrows=2,
                                       ncols=2,
                                       figsize=(7,4))

it will defiantly help

Gavish
  • 1