2012-09-05 6 views
7

मैं निम्नलिखित कोड के साथ xticks के बीच अच्छे रिक्त स्थान प्राप्त करने में सक्षम नहीं कर रहा हूँ:matplotlib xticks लेबल ओवरलैप

import random 
import matplotlib.pyplot as plt 

coverages = [random.randint(1,10)*2] * 100 
contig_names = ['AAB0008r'] * len(coverages) 
fig = plt.figure() 
fig.clf() 
ax = fig.add_subplot(111) 

ax.yaxis.grid(True, linestyle='-', which='major', color='grey', alpha=0.5) 

ind = range(len(coverages)) 
rects = ax.bar(ind, coverages, width=0.2, align='center', color='thistle') 
ax.set_xticks(ind) 
ax.set_xticklabels(contig_names) 
#function to auto-rotate the x axis labels 
fig.autofmt_xdate() 

plt.show() 

कैसे xticks के बीच और अधिक स्थान की तो वे अब और ओवरलैप की तरह मत देखो पाने के लिए?

अग्रिम धन्यवाद।

उत्तर

8

आप आंकड़ा आकार, xticklabels के आकार, रोटेशन के अपने कोण, आदि

# Set the figure size 
fig = plt.figure(1, [20, 8]) 

# Set the x-axis limit 
ax.set_xlim(-1,100) 
# Change of fontsize and angle of xticklabels 
plt.setp(ax.get_xticklabels(), fontsize=10, rotation='vertical') 
बदलने का प्रयास कर सकते हैं

 संबंधित मुद्दे

  • कोई संबंधित समस्या नहीं^_^