Is it possible to wrap the text of xticks in matplotlib in python? 
Anyone know if it is possible to wrap the xtick labels in matplotlib? Right now I've got the following code (kind of messy -- been hacking at it for a while): 
 

    def plotResults(request, question_id):
     responses = ResponseOption.objects.filter(question__id=question_id).order_by('order').annotate(response_num=Count('response'))
     
     counts = []
     labels = [] 
     
     for response in responses:
      counts.append(response.response_num)
      labels.append(smart_truncate('$'+response.text+'$'))
     
     N = len(labels)
     labels = tuple(labels)
     counts = tuple(counts)
     ind = na.array(range(N))+0.5
     width = .35
     fig = Figure(facecolor='white',edgecolor='white')
     ax = fig.add_subplot(1,1,1)
     
     
     rects1 = ax.bar(ind, counts,linewidth=0)
    
     ax.set_ylabel('$Count$')
    
     ax.set_title('$Response Historgram$')
     ax.set_xticks(ind+width)
     ax.set_xticklabels(labels)
    
     print mpl.matplotlib_fname()
    
     canvas = FigureCanvas(fig)
     response = HttpResponse(content_type='image/png')
    
     canvas.print_png(response)
     
     return response

That generates this plot: http://i.imgur.com/tj8Cm.png

As you can see the xticks are boned. Any ideas on how to wrap them, or baring that make them readable? Thanks again!

PS: This is part of a Django project. I return the plot as a png image -- normally call them from img tags in various views. 


Is it possible to wrap the text of xticks in matplotlib in python? 
===

Anyone know if it is possible to wrap the xtick labels in matplotlib? Right now I've got the following code (kind of messy -- been hacking at it for a while): 
 

    def plotResults(request, question_id):
     responses = ResponseOption.objects.filter(question__id=question_id).order_by('order').annotate(response_num=Count('response'))
     
     counts = []
     labels = [] 
     
     for response in responses:
      counts.append(response.response_num)
      labels.append(smart_truncate('$'+response.text+'$'))
     
     N = len(labels)
     labels = tuple(labels)
     counts = tuple(counts)
     ind = na.array(range(N))+0.5
     width = .35
     fig = Figure(facecolor='white',edgecolor='white')
     ax = fig.add_subplot(1,1,1)
     
     
     rects1 = ax.bar(ind, counts,linewidth=0)
    
     ax.set_ylabel('$Count$')
    
     ax.set_title('$Response Historgram$')
     ax.set_xticks(ind+width)
     ax.set_xticklabels(labels)
    
     print mpl.matplotlib_fname()
    
     canvas = FigureCanvas(fig)
     response = HttpResponse(content_type='image/png')
    
     canvas.print_png(response)
     
     return response

That generates this plot: http://i.imgur.com/tj8Cm.png

As you can see the xticks are boned. Any ideas on how to wrap them, or baring that make them readable? Thanks again!

PS: This is part of a Django project. I return the plot as a png image -- normally call them from img tags in various views. 

