# 7 - GRAFICOS-2D-3D

## 1076 days ago by jmarcellopereira

GRÁFICOS DE DADOS DISCRETOS, DE FUNÇÕES MATEMÁTICAS E DE POLÍGONOS

x = [0.0, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10.0] y = [0.0, 0.84, 1.0, 0.91, 0.6, 0.14, -0.35, -0.76, -0.98, -0.96, -0.71, -0.28, 0.22, 0.66, 0.94, 0.99, 0.8, 0.41, -0.08, -0.54]
point(zip(x,y))

Melhorando o Gráfico

point(zip(x,y),legend_label="pontos x e y", axes_labels=['x','y'], color="red",gridlines="minor",size=50,figsize=(6, 5))

GRÁFICO DE UMA FUNÇÃO

reset()
y = sin(x)*x
# lembrando que se for outra variável, diferente de "x", devemos usar função(variavel) = expressão variável plot(y,(x,0,10))

Melhorando o gráfico

# lembrando que se for outra variável, diferente de "x", devemos usar função(variavel) = expressão variável plot(y,(x,0,10),legend_label=y, axes_labels=['x','y'], color="red",gridlines="minor",thickness=1,figsize=(6, 5),plot_points=20,marker="o",markersize=3)

Gráfico com pontos em destaque

y = sin(x)*x plot(y, (x,0,3), ticks=[[1,2.5],[y(1),y(2.5)]], tick_formatter=[['x1','x2'],['y1','y2']], gridlines=true,figsize=(6, 5)) + point([(1,y(1)),(2.5,y(2.5))],color='red',size=50)
 /home/jmarcellopereira/SageMath/local/lib/python2.7/site-packages/sage/a\ ll_notebook.py:5: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...) See http://trac.sagemath.org/5930 for details. import sys /home/jmarcellopereira/SageMath/local/lib/python2.7/site-packages/sage/all_notebook.py:5: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...) See http://trac.sagemath.org/5930 for details. import sys

GRÁFICOS MULTIPLOS

reset()
y = sin(x)*x g = cos(x)*x
plot(y,(x,0,10))+ plot(g,(x,0,10))

Melhorando

plot(y,(x,0,10),legend_label=y, axes_labels=['x','y'],color = 'red',gridlines='minor',thickness=1,figsize=(6, 5),plot_points=20,marker='o',markersize=3)+ plot(g,(x,0,10),color='black',legend_label=g,plot_points=20,marker='*',markersize=3)

graf1 = plot(y,(x,0,10),legend_label=y, axes_labels=['x','y'],color = 'red',gridlines='minor',thickness=1,figsize=(6, 5),plot_points=20,marker='o',markersize=3) graf2 = plot(g,(x,0,10),legend_label=g, axes_labels=['x','y'],color = 'blue',gridlines='minor',thickness=1,figsize=(6, 5),plot_points=20,marker='*',markersize=3) show(graf1); show(graf2)

graf1 = plot(y,(x,0,10),legend_label=y, axes_labels=['x','y'],color = 'red',gridlines='minor',thickness=1,figsize=(6, 5),plot_points=20,marker='o',markersize=3) graf2 = plot(g,(x,0,10),legend_label=g, axes_labels=['x','y'],color = 'blue',gridlines='minor',thickness=1,figsize=(6, 5),plot_points=20,marker='o',markersize=3) graphics_array([[graf1, graf2]]) ; show(graf1,graf2)

Gráfico função simbólica

f(x) = x^(-1)*sin(x)
plot(f(x),(x,0,10),legend_label=('funcao:', f(x)), axes_labels=['x','y'],color = 'blue',gridlines='minor',thickness=1,figsize=(6, 5),plot_points=20,marker='o',markersize=3);

GRÁFICO EQUAÇÃO IMPLÍCITA

var('x,y')
 (x, y) (x, y)
implicit_plot(y^2 + x^2 - 4, (x, -2, 2), (y, -2, 2),color = 'black', gridlines='minor', figsize=(6, 5))

Melhorando. Acrescentando o raio

implicit_plot(y^2 + x^2 == 4, (x, -2, 2), (y, -2, 2),color = 'black', gridlines='minor',figsize=(6, 5)) + line([(0,0), (2,0)]) + text('Raio', (0.5,0.1))

GRÁFICO EQUAÇÃO PARAMÉTRICA

para funções de x.... para outras variáveis , definir var("variavel")

reset()
parametric_plot((cos(x), sin(x)), (x, 0, 2*pi),fill=True, fillcolor='blue',figsize=(6, 5))

Melhorando o gráfico

parametric_plot((cos(x), sin(x)), (x, 0, 2*pi),fill=True, fillcolor='blue',aspect_ratio=1, figsize=(5, 5), frame=True, gridlines='minor')

Contornos

var('x y')
 (x, y) (x, y)
f = x^2 + y^2 contour_plot(f,(x,-4,4),(y,-4,4),gridlines='true',axes=true)

Gráfico de uma região

var('y') region_plot(x^2 + y^2 < 1,(x,-2,2),(y,-2,2))
region_plot(x + y > 5,(x,-8,8), (y,-8,8), incol="red", outcol="yellow",figsize = (4,3),bordercol='black')
# equivalente a -5 < x + y < 5 region_plot([x + y < 5,x + y >- 5],(x,-8,8), (y,-8,8), incol="red", outcol="yellow",figsize = (4,3),bordercol='black')
region_plot([x^2 + y^2 < 1, x < y], (x,-2,2), (y,-2,2),incol="blue", outcol="gray",bordercol='black',figsize = (4,3))
region_plot(lambda x,y: x^2 + y^2 < 1 and x < y, (x,-2,2), (y,-2,2),incol="blue", outcol="green",bordercol='black',figsize = (4,3))

GRÁFICOS 3D

var('x,y')
 (x, y) (x, y)
plot3d(cos(y^2+x^2)*x^2 + exp(x)*sin(x^2)+ cos(x)*sin(y), (x,-2,2), (y,-2,2),color='blue', mesh = true);

%%% FIM GRAFICOS 2D 3D %%%%