-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx9.py
More file actions
30 lines (22 loc) · 890 Bytes
/
Ex9.py
File metadata and controls
30 lines (22 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# O seguinte exemplo ilustra o traçado de várias curvas em uma mesma janela e o uso de comandos para especificar os
# limites dos eixos e para atribuir um título ao gráfico e legendas aos eixos e às curvas:
import numpy as np
import matplotlib.pyplot as plt
# definindo os pontos do eixo x:
x = np.arange(0.0, 1.0, 0.1)
# plotando 4 curvas:
plt.plot(x, x**2, label='$y = x^2$')
plt.plot(x, x**3, label='$y = x^3$')
plt.plot(x, x**(1/2), label='$y = \sqrt{x}$')
plt.plot(x, x**(1/3), label='$y = \sqrt[3]{x}$')
# limites dos eixos: função axis
# o argumento deve ser uma lista na forma [xmin, xmax, ymin, ymax]
plt.axis([0, 1, 0, 1])
# título do gráfico: função title
plt.title('Gráficos boladões')
# legendas dos eixos: funções xlabel e ylabel
plt.xlabel('Eixo x boladão')
plt.ylabel('Eixo y boladão')
# legendas das curvas: função legend
plt.legend()
plt.show()