SOLVED - см. комментарий ниже о объединении wraptext.wrap
и plt.tightlayout
.
ПРОБЛЕМА: Здесь код:
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()
Это создает фигуру, похожую на
Заголовок обрезается, как я могу заставить его отображать весь заголовок?
UPDATE. Я ищу решение, которое приводит к тому, что размер фигуры соответствует тексту в названиях и топорах, а не для решения, которое сокращает заголовок с помощью строк перевода, в качестве такого решение не всегда помогает:
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()`
Посмотрите результат: