import matplotlib.pyplot as plt
plt.figtext(.5,.9,'Temperature', fontsize=100, ha='center')
plt.figtext(.5,.8,'Humidity',fontsize=30,ha='center')
plt.show()
也许你想要这个。您可以很容易地调整两者的fontsize,并通过更改前两个figtext位置参数来调整放置位置。
ha代表horizontal alignment
或者import matplotlib.pyplot as plt
fig = plt.figure() # Creates a new figure
fig.suptitle('Temperature', fontsize=50) # Add the text/suptitle to figure
ax = fig.add_subplot(111) # add a subplot to the new figure, 111 means "1x1 grid, first subplot"
fig.subplots_adjust(top=0.80) # adjust the placing of subplot, adjust top, bottom, left and right spacing
ax.set_title('Humidity',fontsize= 30) # title of plot
ax.set_xlabel('xlabel',fontsize = 20) #xlabel
ax.set_ylabel('ylabel', fontsize