PROBLEM:
Here’s the code:
import matplotlib.pyplot as plt
plt.bar([1,2],[5,4])
plt.title('this is a very long title and therefore it gets cropped which is an unthinkable behaviour as it loses the information in the title')
plt.show()
This creates a figure looking like:

The title is cropped, how can I get it to display the entire title?
I’m looking for a solution that causes the figure size to match the text in the title and axes labels, not for a solution that cuts the title with newlines, as that kind of solution doesn’t always help:
from textwrap import wrap
import matplotlib.pyplot as plt
title = 'this is a very long title and therefore it gets cropped which is an unthinkable behaviour as it loses the information in the title'*5
plt.bar([1,2],[5,4])
plt.title('\n'.join(wrap(title,60)))
plt.show()`
See the result:

You can try the solution found here.
It’s quite a bit of code, but it seems to handle text wrapping for any sort of text on the plot.
Here’s the code from the solution, modified to fit your example:
This produces the following plot:

UPDATE:
Use the following line to create more space between the top of the figure and the top of the actual plot:
For example, if you use:
The output will look like:
