Там есть аналогичный вопрос - но я не могу заставить предлагаемое там решение работать.
Здесь примерный график с длинным названием:
#!/usr/bin/env python
import matplotlib
import matplotlib.pyplot
import textwrap
x = [1,2,3]
y = [4,5,6]
# initialization:
fig = matplotlib.pyplot.figure(figsize=(8.0, 5.0))
# lines:
fig.add_subplot(111).plot(x, y)
# title:
myTitle = "Some really really long long long title I really really need - and just can't - just can't - make it any - simply any - shorter - at all."
fig.add_subplot(111).set_title("\n".join(textwrap.wrap(myTitle, 80)))
# tight:
(matplotlib.pyplot).tight_layout()
# saving:
fig.savefig("fig.png")
он дает
AttributeError: 'module' object has no attribute 'tight_layout'
и если я заменил (matplotlib.pyplot).tight_layout()
на fig.tight_layout()
, он даст:
AttributeError: 'Figure' object has no attribute 'tight_layout'
Итак, мой вопрос: как мне соответствовать заголовку сюжета?