Q: Matplotlib pyplot title formatting Image
New to using matplotlib, doing some college project. How do I add spacing between two vertical graphs since the values of the first graph area overlapping with the title of the graph below it.
My code used for plotting the graph
    # plot loss
    pyplot.subplot(211)
    pyplot.title('Cross Entropy Loss')
    pyplot.plot(history.history['loss'], color='red', label='train')
    pyplot.plot(history.history['val_loss'], color='black', label='test')
    # plot accuracy
    pyplot.subplot(212)
    pyplot.title('Classification Accuracy')
    pyplot.plot(history.history['accuracy'], color='red', label='train')
    pyplot.plot(history.history['val_accuracy'], color='black', label='test')
    # save plot to file
    filename = sys.argv[0].split('/')[-1]
    pyplot.savefig(filename + '_plot.png')
    pyplot.close()


A: The simplest workaround is to set pyplot.tight_layout() after all the plot() calls:
...
pyplot.plot(history.history['val_accuracy'], color='black', label='test')
pyplot.tight_layout()
# save plot to file
...


