1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| import numpy as np
import matplotlib.pyplot as plt
from matplotlib import pylab
y = np.random.normal( loc=50, scale=10, size=500)
ax1=plt.subplot(2,1,1)
classes = np.linspace(0, 100, 20)
plt.hist(y,bins=classes)
#plt.subplot(2,1,2)
ax2 = plt.subplot(212, sharex=ax1)
classes = np.arange(0,100,1)
h, bin_edges = np.histogram(y,classes)
for dist, eff in zip(classes,h): # distance dans mon histogramme + effectif dans chaque classe
for e in np.arange(eff): # np.arrange(3) = array([0, 1, 2])
#print "%d,%d : %d" %(dist,eff,e)
plt.plot(dist,-e,'sg') # pour qu'il n'y ait pas d'overlappe
plt.xlim(0,100)
ax1.xaxis.tick_top()
ax2.axes.get_xaxis().set_visible(False)
ax2.axes.get_yaxis().set_visible(False)
plt.setp( ax2.get_xticklabels(), visible=False)
plt.setp( ax2.get_yticklabels(), visible=False)
plt.show() |
Partager