I am new to Matplotlib and I have this problem of text(title) in graph overlapping when using subplots. I know about tight_layout() but I am not sure how to use it or something similar to solve the problem.
So, I have the following code:
plt.figure(figsize=(20,4))
for plotIndex,badIndex in enumerate(misclassifiedIndexes[0:10]):
plt.subplot(1,10,plotIndex+1)
plt.imshow(np.reshape(X_test[badIndex],(8,8)),cmap=plt.cm.gray)
plt.title("Predicted: {}, Actual: {}".format(predictions[badIndex],y_test[badIndex]))
The output was: Predicted and Actual texts are overlapping when put in 1st row together using subplot
Now I tried this...
plt.figure(figsize=(20,4))
for plotIndex,badIndex in enumerate(misclassifiedIndexes[0:10]):
plt.subplot(2,5,plotIndex+1)
plt.imshow(np.reshape(X_test[badIndex],(8,8)),cmap=plt.cm.gray)
plt.title("Predicted: {}, Actual: {}".format(predictions[badIndex],y_test[badIndex]))
And the output was: Predicted and Actual texts are overlapping with axes
I don't know how to solve this overlapping text problem in both images. Please suggest me how to avoid (1) overlapping of titles togetheras in the first picture and (2) overlapping of titles with axes Thank you :D