python - Why is my xlabel cut off in my matplotlib plot? -


i plotting dataset using matplotlib have xlabel quite "tall" (it's formula rendered in tex contains fraction , therefore has height equivalent of couple of lines of text).

in case, bottom of formula cut off when draw figures. changing figure size doesn't seem this, , haven't been able figure out how shift x-axis "up" make room xlabel. reasonable temporary solution, nice have way make matplotlib recognize automatically label cut off , resize accordingly.

here's example of mean:

import matplotlib.pyplot plt  plt.figure() plt.ylabel(r'$\ln\left(\frac{x_a-x_b}{x_a-x_c}\right)$') plt.xlabel(r'$\ln\left(\frac{x_a-x_d}{x_a-x_e}\right)$') plt.show() 

while can see entire ylabel, xlabel cut off @ bottom.

in case machine-specific problem, running on osx 10.6.8 matplotlib 1.0.0

use:

import matplotlib.pyplot plt  plt.gcf().subplots_adjust(bottom=0.15) 

to make room label.

edit:

since gave answer, matplotlib has added tight_layout() function. suggest use it:

plt.tight_layout() 

should make room xlabel.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -