Skip to content

Instantly share code, notes, and snippets.

@mia-0032 mia-0032/02_graph.py
Created Aug 23, 2013

Embed
What would you like to do?
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
You can’t perform that action at this time.