C'è un similar question - ma non riesco a far funzionare la soluzione proposta.Come si inserisce il titolo lungo?
Ecco una trama esempio con un titolo lungo:
#!/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")
dà un
AttributeError: 'module' object has no attribute 'tight_layout'
e se sostituisco (matplotlib.pyplot).tight_layout()
con fig.tight_layout()
dà:
AttributeError: 'Figure' object has no attribute 'tight_layout'
Quindi la mia domanda è - come posso adattare il titolo alla trama?
'tight_layout' è solo nell'ultimo paio di uscite di matplotlib. Che versione stai usando? Penso che 'tight_layout' è stato aggiunto in 1.1, anche se potrebbe essere stato 1.0. –
Il mio è '1.0.1'. – Adobe
@Joe Kington: Probabilmente hai ragione: riprodurre la tua [risposta] (http://stackoverflow.com/a/9604442/788700) dà lo stesso errore. Sto scaricando l'ultima fonte. – Adobe