Python Matplotlib figure title overlaps axes label when using twiny
I'm not sure whether it is a new feature in later versions of matplotlib, but at least for 1.3.1, this is simply:
plt.title(figure_title, y=1.08)
This also works for plt.suptitle()
, but not (yet) for plt.xlabel()
, etc.
Turning figure or axes title off
You can use
ax.set_title("default title") # always set a default title
ax.title.set_visible(title) # set on or off
To toggle, you could do
ax.title.set_visible(not ax.title.get_visible())
Increase distance between title and plot in matplolib?
There doesn't seem to be a clean way to set this directly (but might be worth a feature request to add that), however the title is just a text
artist, so you can reach in and change it.
#ax = plt.gca()
ttl = ax.title
ttl.set_position([.5, 1.05])
#plt.draw()
should do the trick. Tune the 1.05
to your liking.
Related Topics
Python: Urllib2 How to Send Cookie with Urlopen Request
Difference Between Pygame.Display.Update and Pygame.Display.Flip
Using Django Database Layer Outside of Django
For Loops and Iterating Through Lists
Python Time + Timedelta Equivalent
Are Sets Ordered Like Dicts in Python3.6
Use Python Requests to Download CSV
How to Read the Contents of an Url with Python
Plot a Bar Using Matplotlib Using a Dictionary
Django Model Field Default Based Off Another Field in Same Model
Correct Style for Python Functions That Mutate the Argument
Keep Persistent Variables in Memory Between Runs of Python Script
Logging, Streamhandler and Standard Streams
Why Does Python's Multiprocessing Module Import _Main_ When Starting a New Process on Windows
Why Does Appending to One List Also Append to All Other Lists in My List of Lists
SchröDinger's Variable: the _Class_ Cell Magically Appears If You'Re Checking for Its Presence