Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Jupyter notebook TutorialGraficar.ipynb

Project: Python
Views: 170
Kernel: Python 2 (system-wide)
# Librerias necesarias import matplotlib.pyplot as plt import numpy as np from __future__ import division # para que las graficas se visualicen en el navegador %matplotlib inline # vector de variable independiente x = np.linspace(-4,4,500) # linspace es comando de numpy (np) # vector a graficar y=x*np.exp(-x)/(1+x**3) # comando para graficar plt.plot(x,y) # plot es comando de matplotlib (plt)
[<matplotlib.lines.Line2D at 0x7f1f50f8ac10>]
Image in a Jupyter notebook
# Cambiando los limites para mejor visualizacion plt.plot(x,y) plt.ylim(-10,10) plt.xlim(-2,2) # Poniendo titulo a grafica plt.title(r'Ejemplo grafica de $\frac{xe^{-x}}{1-x^2}$')
<matplotlib.text.Text at 0x7f1f4fabc750>
Image in a Jupyter notebook
# Otra forma de cargar las librerias necesarias para no usar "np" o "plt" from matplotlib.pyplot import * from numpy import * from __future__ import division %matplotlib inline # Para graficar familias de curvas x=linspace(-5,5,500) fig, ax = subplots() for C in range(-4,4,1): y=C*exp(-x**2) ax.plot(x,y,label="Para $C=%s$" %C) xlim(-5,7) legend(loc="best")
<matplotlib.legend.Legend at 0x7f0e9c5063d0>
Image in a Jupyter notebook
# Graficacion de funciones implicitas # definicion de la funcion a graficar def f(x,y): return x**2/2-y**2-exp(-x*y) # vectores para x y y x=linspace(-10,10,500) y=linspace(-10,10,500) # construccion de malla X, Y = np.meshgrid(x, y) # grafica contour(X, Y, f(X, Y),[0],colors='b') title(r'Ejemplo grafica de $\frac{x^2}{2}-y^2-e^{-xy}=0$')
<matplotlib.text.Text at 0x7f0e74a85150>
Image in a Jupyter notebook