web-dev-qa-db-fra.com

modification de la plage x par défaut dans l'histogramme

Je voudrais changer la plage x par défaut pour le tracé de l'histogramme. La plage de données va de 7 à 12. Cependant, par défaut, l’histogramme commence à 7 et se termine à 13. Je veux qu’il commence à 6,5 et se termine à 12,5. Cependant, les tics devraient aller de 7 à 12. Comment puis-je le faire? 

import asciitable 
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import pylab
from pylab import xticks

data = asciitable.read(file)
hmag = data['col8']
visits = data['col14']
Origin = data['col13']


n, bins, patches = plt.hist(hmag, 30, facecolor='gray', align='mid')
xticks(range(7,13))
pylab.rc("axes", linewidth=8.0)
pylab.rc("lines", markeredgewidth=2.0) 
plt.xlabel('H mag', fontsize=14)
plt.ylabel('# of targets', fontsize=14)
pylab.xticks(fontsize=15)
pylab.yticks(fontsize=15)
plt.grid(True)
plt.savefig('hmag_histogram.eps', facecolor='w', edgecolor='w', format='eps')
plt.show()
16
Rohit
plt.hist(hmag, 30, range=[6.5, 12.5], facecolor='gray', align='mid')
38
tiago
import matplotlib.pyplot as plt


...


plt.xlim(xmin=6.5, xmax = 12.5)
0
Erich