- 작성시간 : 2014/04/27 21:23
- 퍼머링크 : always19.egloos.com/2978549
- 덧글수 : 0
파이선으로 점 그래프 그리기
matplotlib.pyplot.hist(x, bins=10, range=None, normed=False, weights=None, cumulative=False, bottom=None, histtype='bar',align='mid', orientation='vertical', rwidth=None, log=False, color=None, label=None, stacked=False, hold=None, **kwargs)

처음에 python program은 뜨는데, 그래프가 안나와서 한참 고생했네.
1) Part of the magic of ipython is that when you plot in ipython's pylab mode, you don't need to explicitly invoke pyplot.show(). From your script, you do need to.
https://support.enthought.com/entries/25750190-Modules-are-already-available-in-the-pylab-python-prompt-but-not-in-a-script (bottom of article)
histogram 그리기
for i in range(0, n_people):
slot = random.randint(0, n_slots - 1)
slot_histogram[slot] = slot_histogram[slot] + 1
hist 함수를 쓰면, 이 계산을 할 필요 없었겠다.
Plot a histogram.
Compute and draw the histogram of x. The return value is a tuple (n, bins, patches) or ([n0, n1, ...], bins, [patches0, patches1,...]) if the input contains multiple data.
x, y값을 모두 아는 경우에는 hist를 할 필요가 없었다.
그냥 모든 점을 plot
분포가 예쁘게 안나와서 주위 30개 정도를 평균낸 값을 그 위치 값으로 했더니, histogram을 그리지 않아도 예쁜 그래프가 나왔다.



덧글