Issue
I've 2 subplots in a single row. Below is the code:-
plt.suptitle('Water Vapor Count for Fani before landfall') #Overall plot title.
fig,(ax1,ax2)=plt.subplots(nrows=1,ncols=2,figsize=(15,15)) #Defining the figure and axes
image_wv_global=ax1.imshow(wvcount,vmin=800,vmax=975,label="Global") #First image
plt.colorbar(image_wv_global,ax=ax1,fraction=0.046, pad=0.04) #Colorbar for first image, declaring the axis in it is v.imp.
image_wv_asia=ax2.imshow(wvcount,vmin=800,vmax=975,label="Asia specific") #Second image
plt.axis([300, 1000, 200, 700]) #Axis restriction for asia-specific plot
plt.colorbar(image_wv_asia,fraction=0.046,ax=ax2, pad=0.04) #Colorbar for 2nd subplot
ax1.title.set_text('Global plot') #1st subplot title
ax2.title.set_text('Asia-specific plot') #2nd subplot title
ax1.grid()
ax2.grid()
fig.suptitle('Main title',ha='center',va='bottom')
#fig.tight_layout()
plt.show()
Everything is working fine except that there's a unwanted huge gap between the main plot-title and the 2 subplots as shown in this image.
I've tried setting the alignment for matplotlib.suptitle
using ha=center
and va=top
but to no avail. Even using va=bottom
or va=baseline
isn't working.
Any suggestions?
Solution
This is how I am getting after generating some random data:
Just by deleting this row:
plt.suptitle('Water Vapor Count for Fani before landfall') #Overall plot title.
and modified this row:
fig.suptitle('Main title',ha='center',va='bottom')
to:
fig.suptitle('Water Vapor Count for Fani before landfall')
Answered By - aliwimo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.