एक similar question है - लेकिन मैं वहां समाधान प्रस्तावित समाधान नहीं कर सकता।मैं लंबे शीर्षक कैसे फिट करूं?
#!/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'
देता है और अगर मैं fig.tight_layout()
साथ (matplotlib.pyplot).tight_layout()
की जगह यह देता है::
AttributeError: 'Figure' object has no attribute 'tight_layout'
तो मेरे सवाल का
यहाँ एक लंबे शीर्षक के साथ एक उदाहरण साजिश है है - मैं साजिश में शीर्षक कैसे फिट करूं? आप लिंक किए गए कई अन्य अच्छा समाधान है कि जोड़ने नई-पंक्तियों को शामिल कर रहे हैं
import pylab as plt
plt.rcParams["axes.titlesize"] = 8
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."
plt.title(myTitle)
plt.show()
जवाब में:
'tight_layout' केवल matplotlib की विज्ञप्ति के पिछले कुछ में है। आप कौन सा संस्करण उपयोग कर रहे हैं? मुझे लगता है कि 'tight_layout' 1.1 में जोड़ा गया था, हालांकि यह 1.0 हो सकता है। –
मेरा '1.0.1' है। – Adobe
@ जो किंगटन: शायद आप सही: अपने [उत्तर] को पुन: उत्पन्न करना (http://stackoverflow.com/a/9604442/788700) एक ही त्रुटि देता है। मैं नवीनतम स्रोत डाउनलोड कर रहा हूँ। – Adobe