tikz

20
GRAFICAS CON TIKZ Jhony Sandoval Ju´ arez February 16, 2014 Jhony Sandoval Ju´ arez GRAFICAS CON TIKZ

Upload: robert-ipanaque-chero

Post on 12-Apr-2017

382 views

Category:

Education


1 download

TRANSCRIPT

GRAFICAS CON TIKZ

Jhony Sandoval Juarez

February 16, 2014

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

EL COMANDO TikZ

En la siguiente presentacion haremos uso de las nocionesbasicas de crear graficas nativas usando el editor cientıficoLATEX.Para esto haremos uso del paquete TikZ y de LATEXDraw.En primer lugar usaremos el paquete TikZ que sirve para creargraficos para documentos LATEX, usando el ambiente’tikzpicture’. Para usar estepaquete debemos escribir en elpreambulo \usepackage{tikz} y \usepackage{etex}

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

EL COMANDO TikZ

Usando el comando tikz podemos usar el comando \tikz paracrear por ejemplo un circulo. Escribamos el siguiente codigo:

\tikz \fill[orange] (1ex,1ex) circle (6ex);

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

EL COMANDO TikZ

Aquı el punto y coma (;) es importante. Inmediatamentecompilamos y nos arrojara el siguiente resultado:

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

EL COMANDO TikZ

podemos reducir el tamano y el color de nuestro circulo,cambiando las dimensiones en nuestro codigo:

\fill[red] (1ex,1ex) circle (4ex);

Recalcamos que aquı el punto y coma (;) es importante. elresultado obtenido es:

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

EL COMANDO tikzpicture

A diferencia del comando TikZ que me permite graficas decircunferencias, el comando tikzpicture es un comando que nospermite graficar rectas, cuadrilateros, rectangulos, cırculos,etc. para hacer esto se usa el comando \draw.

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

EL COMANDO tikzpicture

Por ejemplo, editemos el siguiente codigo:

\begin{center}\selectlanguage{english}\begin{tikzpicture}[>=stealth]\draw [− >] (-1.5,0) −− (1.5,0);\end{tikzpicture}\selectlanguage{spanish}\end{center}

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

EL COMANDO tikzpicture

para que este codigo compile, es necesario escribir antes del\begin{tikzpicture} el comando \selectlanguage{english} y alfinal \selectlanguage{spanish}. Pero para que estos comandosfuncionen se debemos agregar, en el paquete\usepackage[spanish]{babel} del preambulo,\usepackage[spanish,english]{babel}. El resultado sera unarecta tal como muestra la figura:

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

EL COMANDO tikzpicture

Hagamos por ejemplo, dos rectas perpendiculares queasemejen a un plano coordenado, ecribamos el siguientecodigo:

\begin{center}\selectlanguage{english}\begin{tikzpicture}[>=stealth]\draw [− >] (-1.5,0) −− (1.5,0);\draw [− >] (0,-1.5) −− (0,1.5);\end{tikzpicture}\selectlanguage{spanish}\end{center}

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

EL COMANDO tikzpicture

La grafica del codigo anterior seran dos rectas que asemejanun plano de coordenadas

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

EL COMANDO tikzpicture

ecribamos el siguiente codigo:

\begin{center}\selectlanguage{english}\begin{tikzpicture}[>=stealth]\draw [− >] (-1.5,0) −− (1.5,0);\draw [− >] (0,-1.5) −− (0,1.5);\shadedraw (0.5,0.5) circle (0.5cm);\end{tikzpicture}\selectlanguage{spanish}\end{center}

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

EL COMANDO tikzpicture

Lo que me definira la figura:

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

EL COMANDO tikzpicture

para hacer un circulo con relleno de color, o un cuadrado conrelleno de color, usaremos el comando \filldraw.

\begin{center}\selectlanguage{english}\begin{tikzpicture}[>=stealth]\draw [− >] (-1.5,0) −− (1.5,0);\draw [− >] (0,-1.5) −− (0,1.5);\filldraw [fill=red,,even odd rule]

(-1,-1) rectangle (0,0);\filldraw[fill=magenta,even odd rule]

(0.5,0.5) circle(0.5);\end{tikzpicture}\selectlanguage{spanish}\end{center}Jhony Sandoval Juarez

GRAFICAS CON TIKZ

EL COMANDO tikzpicture

La grafica obtenida del codigo anterior sera:

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

GRAFICAS DE FUNCIONES PRIMITIVAS CON

TikZ

En LATEX, para graficar funciones usaremos el comando \plot.Aquı, la asignacion de la variable estara dada por \x. Eldominio en el cual queremos graficar nuestra funcion ladefiniremos mediante domain:=a:b, esta especificacion seejecuta del comando \draw.

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

GRAFICAS DE FUNCIONES PRIMITIVAS CON

TikZ

Digitemos el siguiente codigo:

\begin{center}\begin{tikzpicture}[scale=0.8]\draw[− >] (-4,0) −− (4,0) node[right] {$x$};\draw[− >] (0,-3) −− (0, 4) node[left] {$y$};\draw[smooth, domain = -2:2, color=red]plot(\x,\x ∗ \x) node[right] {$ y = x2 $};\end{tikzpicture}\end{center}

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

GRAFICAS DE FUNCIONES PRIMITIVAS CON

TikZ

Escribiendo dicho codigo, estamos graficando la parabolay = x2, cuya grafica se ve a continuacion:

x

y y = x2

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

GRAFICAS DE FUNCIONES PRIMITIVAS CON

TikZ

Grafiquemos ahora la funcion cos(x) y la funcion exp(x), condominio en [0, 2π]. Digitemos el siguiente codigo:

\begin{center}\begin{tikzpicture}[scale=0.8]\draw[− >] (-4,0) −− (6,0) node[right] {$x$};\draw[− >] (0,-2) −− (0,4) node[left] {$y$};\draw[smooth, domain = 0:2*pi, color=red]plot (\x,{cos(\x r)}) node[right] {y = cos(x)};\draw[smooth, domain = -2:2, color=blue]plot (\x,{exp(\x - 1)}) node[right] {y = exp(x − 1)};\end{tikzpicture}\end{center}

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

GRAFICAS DE FUNCIONES PRIMITIVAS CON

TikZ

las graficas generadas seran:

x

y

y = cos(x)

y = exp(x − 1)

Jhony Sandoval Juarez

GRAFICAS CON TIKZ

MUCHAS GRACIAS

Jhony Sandoval Juarez

GRAFICAS CON TIKZ