rotating xticks causes the ticks partially hidden in matplotlib

Viewed 20032

I am creating a plot with names on x axis and time values(minutes) on y axis.The names on x axis are like

 ['cooking']18:15:27 ,['study']18:09:19,['travel']18:21:34` etc ..

where as the y values are 5,1,1 etc.I have given xlabel as 'categories' and ylabel as 'durations in minutes'.

Since the xticks were strings of some length,I decided to rotate them by 90 to avoid overlapping.Now ,the ticks are partially hidden and the xlabel has disappeared. plot where xticks get partially hidden and xlabel disappears Is there some way I can make the whole plot accommodate everything..?

thanks

mark

here is the code snippet

import matplotlib.pyplot as plt
...
figure = plt.figure()
barwidth = 0.25
ystep = 10
plt.grid(True)
plt.xlabel('categories')
plt.ylabel('durations in  minutes')
plt.title('durations for categories-created at :'+now)
plt.bar(xdata, ydata, width=barwidth,align='center')
plt.xticks(xdata,catnames,rotation=90)
plt.yticks(range(0,maxduration+ystep,ystep))
plt.xlim([min(xdata) - 0.5, max(xdata) + 0.5])
plt.ylim(0,max(ydata)+ystep)
figure.savefig("myplot.png",format="png")
3 Answers
Related