Skip to content

Instantly share code, notes, and snippets.

@alcides
Created January 12, 2017 20:23
Show Gist options
  • Save alcides/72e5b5ca09d2d054d3bf4da3568c6445 to your computer and use it in GitHub Desktop.
Save alcides/72e5b5ca09d2d054d3bf4da3568c6445 to your computer and use it in GitHub Desktop.
Histogram in Python using Matplotlib
a = """
6,66
5,88
2,33
5,85
5,68
6,15
5,98
6,96
4,33
2,43
6,90
3,03
7,00
4,06
6,90
6,18
4,23
4,83
1,15
7,10
4,98
1,35
4,83
5,88
5,06
4,93
7,40
4,83
5,25
4,15
4,63
6,40
3,83
4,26
5,55
5,58
0,50
1,38
6,31
2,80
6,16
5,48
6,03
6,90
6,68
3,85
2,43
7,88
5,55
3,86
5,73
7,58
1,75
3,85
4,46
5,95
1,95
1,95
5,95
4,03
5,81
5,38
6,83
5,91
2,80
7,23
6,35
5,43
5,65
5,93
3,88
3,08
7,88
6,25
6,13
7,98
6,51
0,95
6,28
7,20
4,80
6,38
3,08
5,78
7,63
4,01
4,33
4,91
2,98
6,11
1,33
4,48
5,06
6,93
3,88
3,60
7,30
6,70
7,18
3,85
5,05
5,06
5,13
5,56
6,33
5,08
4,73
6,68
4,13
1,13
2,75
5,88
5,81
4,26
5,03
5,46
6,43
5,38
7,53
4,38
6,03
6,50
"""
data = [float(i.strip().replace(",", ".")) for i in a.split()]
#!/usr/bin/env python
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
mu, sigma = 100, 15
x = mu + sigma*np.random.randn(10000)
# the histogram of the data
n, bins, patches = plt.hist(data, 50, normed=1, facecolor='green', alpha=0.75)
plt.savefig("p.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment