Created
August 23, 2013 17:13
-
-
Save mia-0032/6321746 to your computer and use it in GitHub Desktop.
Pythonでヒストグラムと箱ひげ図を描く
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
import numpy | |
import pylab | |
#データの生成 | |
n = 200 | |
score_x = numpy.random.normal(171.77, 5.54, n) | |
score_y = numpy.random.normal(62.49, 7.89, n) | |
score_x.sort() | |
score_x = numpy.around(score_x + numpy.random.normal(scale=3.0, size=n), 2) | |
score_y.sort() | |
score_y = numpy.around(score_y + numpy.random.normal(size=n), 2) | |
#ヒストグラムを描く | |
pylab.subplot(221) | |
pylab.hist(score_x, 10) | |
#箱ひげ図を描く | |
pylab.subplot(222) | |
pylab.boxplot(score_x) | |
#yについても同じく | |
pylab.subplot(223) | |
pylab.hist(score_y, 10) | |
pylab.subplot(224) | |
pylab.boxplot(score_y) | |
pylab.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment