Skip to content

Instantly share code, notes, and snippets.

@mia-0032
Created August 23, 2013 17:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mia-0032/6321746 to your computer and use it in GitHub Desktop.
Save mia-0032/6321746 to your computer and use it in GitHub Desktop.
Pythonでヒストグラムと箱ひげ図を描く
# -*- 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