0

Here is my sample data:

aa=pd.DataFrame({'x':[2011.0,2012.0,2013.0,2014.0],
                 'y':[2011.0,2012.0,20113.0,2014.0],
                 'group':['a','b','c','d']})
fig = plt.figure()
fig.suptitle('**************************')
ax = fig.add_subplot(2,2,1)
aa1=aa.loc[(aa['group']=='a')]
p=ax.scatter(aa1.loc[:,'x'],aa1.loc[:,'y'],alpha=.7,s=3,color='blue')
ax.set_title('a')
plt.xticks(rotation=45)
ax = fig.add_subplot(2,2,2)
aa1=aa.loc[(aa['group']=='b')]
p=ax.scatter(aa1.loc[:,'x'],aa1.loc[:,'y'],alpha=.7,s=3,color='blue')
ax.set_title('b')
plt.xticks(rotation=45)
ax = fig.add_subplot(2,2,3)
aa1=aa.loc[(aa['group']=='c')]
p=ax.scatter(aa1.loc[:,'x'],aa1.loc[:,'y'],alpha=.7,s=3,color='blue')
ax.set_title('c')
plt.xticks(rotation=45)
ax = fig.add_subplot(2,2,4)
aa1=aa.loc[(aa['group']=='d')]
p=ax.scatter(aa1.loc[:,'x'],aa1.loc[:,'y'],alpha=.7,s=3,color='blue')
ax.set_title('d')
plt.xticks(rotation=45)
#plt.tight_layout()
plt.show()

If I do not use tight_layout:

enter image description here

If I use tight_layout:

enter image description here

I do not want either of them. I hope I can customize the distance between subplots (x and y) by myself.

halfer
  • 19,824
  • 17
  • 99
  • 186
Feng Chen
  • 2,139
  • 4
  • 33
  • 62
  • you can use `matplotlib.pyplot.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)`, to adjust the spacing refer [here](https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.subplots_adjust) – Shijith Jul 30 '19 at 06:15
  • You could use matplotlib.gridspec to adjust the layout, see here: https://matplotlib.org/users/gridspec.html#adjust-gridspec-layout. I have not tried to adjust your code because it is not complete (imports are missing). – thfr Jul 30 '19 at 06:16

0 Answers0