Escolar Documentos
Profissional Documentos
Cultura Documentos
int() float().
append()
bt
y(t ) Ae cos( t )
matplotlib.pylab t
y float t
i t
math
sin exp from math import cos, exp
y[i] = f plot(t,y)
fontsize show()
cap3_graf1v1.py
#cap3_graf1v1.py
'''Exemplo de grafico simples com matplotlib
importando todos os metodos
Programador: Elinei Santos
Data da ultima revisao: 26/12/2016'''
plot
cap3_graf1v2.py
0 , 2t
f1 8e cos(2t)
0 ,15t
f 2 10e cos(2,5t).
b-
linewidth=2) y1 t
b-' linewidth = 2
plot
plot
r-- linewidth = 3
#cap3_graf1v2.py
'''Exemplo de grafico simples com legenda
usando o modulo matplotlib
Programador: Elinei Santos
Data da ultima revisao: 26/12/2016'''
from matplotlib.pylab import *
from math import *
t = linspace(0,30,200)
y1 = zeros(len(t))
y2 = zeros(len(t))
for i in xrange(len(t)):
f1 = 8*exp(-0.2*t[i])*cos(2.*t[i])
f2 = 10*exp(-0.15*t[i])*cos(2.5*t[i])
y1[i] = f1
y2[i] = f2
plot(t,y1,'b-',linewidth = 2)
#hold('on') #utilizado em versoes mais antigas
plot(t,y2,'r--', linewidth = 3)
title('Oscilador harmonico amortecido')
xlabel('tempo(s)', fontsize = 15)
ylabel('y(m)', fontsize = 15)
legend(['f1', 'f2'])
axis([0,30, -8,8])
show()
plot
plot
plot(t,y2,'b-', linewidth = 3)
(t,y2)
0, 2t
f1 4e cos(1,2t / 6)
0, 4t 0, 2t
f2 4e 2e
f 3 (2 2t)e 0, 4t
cap3_graf4.py
#cap3_graf4.py
'''Exemplo de grafico simples com matplotlib
importando todos os metodos
Programador: Elinei Santos
Data da ultima revisao: 26/12/2016'''
from matplotlib.pylab import *
from math import *
t = linspace(0,30,200)
y1 = zeros(len(t))
y2 = zeros(len(t))
y3 = zeros(len(t))
for i in xrange(len(t)):
f1 = 4*exp(-0.1*t[i])*cos(1.2*t[i]+pi/6)
f2 = 4*exp(-0.2*t[i])+2*exp(-0.2*t[i])
f3 = (2.+3*t[i])*exp(-0.3*t[i])
y1[i] = f1
y2[i] = f2
y3[i] = f3
plot(t,y1,'bo')
plot(t,y2,'r^')
plot(t,y3,'ms')
xlabel('tempo(s)', fontsize = 15)
ylabel('y(m)', fontsize = 15)
legend(['f1', 'f2', 'f3'],loc=1)
axis([0,30, -6,6])
show()
loc =1
loc = 1 loc
= 2 loc = 3 loc = 4
loc
xlabel('tempo(s)', fontsize = 15, fontname = 'Times New Roman', family = 'cursive', color ='red')
scatter() (x,y) scatter(x,y)
scatter()
mpl_mapalogistico.py
m (m,y)
plote.scatter(m,y, color='blue', s=0.2) color='blue'
subplot(2,2,1)
subplot(2,2,4),
#mpl_logisticatraj.py
'''programa para gerar uma figura com varios graficos
Programador: Elinei Santos
Data da ultima revisao: 30/12/2016'''
from pylab import *
import math
ys = []
subplot(2,2,1)
m = 3.1
y=0.5
for j in range(40):
y= m*y*(1.-y)
if (j> 2): ys.append(y)
plot(ys,'b',linewidth=2)
axis([0., 16.,0., 1.2])
legend('a')
ys = []
subplot(2,2,2)
m = 3.5
y=0.5
for j in range(40):
y = m*y*(1.-y)
if (j> 2): ys.append(y)
plot(ys,'r',linewidth=2)
axis([0., 16.,0., 1.2])
legend('b')
ys = []
subplot(2,2,3)
m = 3.56
y=0.5
for j in range(40):
y = m*y*(1.-y)
if (j> 2): ys.append(y)
plot(ys,'y',linewidth=2)
axis([0., 16.,0., 1.2])
legend('c')
ys = []
subplot(2,2,4)
m = 3.8
y=0.5
for j in range(40):
y = m*y*(1.-y)
if (j> 2): ys.append(y)
plot(ys,'g',linewidth=2)
axis([0., 16.,0., 1.2])
legend('d')
show()
4 4
F
2 2 2
(x 3) y 2 (x 3) y2 2
#graf_3D.py
'''Programa para visualizar uma função
em 3D
Programador: Elinei Santos'''
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x = np.linspace(-8, 8, 200)
y = np.linspace(-8, 8, 200)
x, y = np.meshgrid(x,y)
z = 4./np.sqrt((x+3)**2+y**2+2)-4/np.sqrt((x-3)**2+y**2+2)
ax.plot_wireframe(x,y,z,color='b', rstride =5, cstride =5)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
plt.show()