Comecemos pelo exemplo básico.
01.
import
random
02.
import
matplotlib.pyplot as plt
03.
04.
05.
def
gera(n):
06.
return
[random.randint(
1
,
6
)
+
random.randint(
1
,
6
)
for
i
in
range(n)]
07.
08.
def
histograma(dados):
09.
plt.hist(dados,
11
)
10.
plt.show()
11.
12.
if
__name__
=
=
'__main__'
:
13.
dados
=
gera(
5000
)
14.
histograma(dados)
1.
def
histograma(dados):
2.
plt.title(
'Dados = '
+
str(len(dados)))
3.
plt.xlabel(
'Resultado'
)
4.
plt.ylabel(
'Frequência'
)
5.
plt.hist(dados,
11
,color
=
'red'
)
6.
plt.show()
1.
def
grafico(x,y):
2.
plt.title(
'y=f(x)'
)
3.
plt.xlabel(
'x'
)
4.
plt.ylabel(
'y'
)
5.
plt.plot(x,y,
'go-'
)
6.
plt.show()
Divirta-se.
Sem comentários:
Enviar um comentário