Grupo de Estudio en Modelamiento Matemático
y
Computo Científico
Alexander Arias
Noviembre de 2017
Sesión 9 Manejo de Python por medio de Interfaces web
COCALC
Crear una cuenta en cocalc
https://cocalc.com/
O ensayar sobre el servidor de Jupyter:
jupyter.org
try in your browser
Ensayar los siguientes comandos en las consolas en línea de comandos de Jupyter o Ipython
---------------------------------------------
print('hello, world.')
---------------------------------------------
---------------------------------------------
import pylab
import numpy as np
x = np.linspace(0, 20, 1000) # 100 evenly-spaced values from 0 to 50
y = np.sin(x)
y = np.sin(x)
---------------------------------------------
---------------------------------------------
pylab.plot(x, y)
pylab.xlim(5, 15)
pylab.ylim(-1.2, 1.2)
---------------------------------------------
---------------------------------------------
import matplotlib.pyplot as plt
fig = plt.figure() # a new figure window
ax = fig.add_subplot(1, 1, 1) # specify (nrows, ncols, axnum)
---------------------------------------------
---------------------------------------------
import numpy as np
x = np.linspace(0, 10, 1000)
y = np.sin(x)
ax.plot(x, y)
display(fig) # this is required to re-display the figure
---------------------------------------------
---------------------------------------------
y2 = np.cos(x)
ax.plot(x, y2)
fig # this works similarly to display(fig)
---------------------------------------------
---------------------------------------------
ax.set_ylim(-1.5, 2.0)
fig
---------------------------------------------
---------------------------------------------
ax.legend(['sine', 'cosine'])
fig
---------------------------------------------
---------------------------------------------
ax.set_xlabel("$x$")
ax.set_ylabel("$\sin(x)$")
ax.set_title("I like $\pi$")
fig
---------------------------------------------
---------------------------------------------
fig = plt.figure()
for i in range(6):
ax = fig.add_subplot(2, 3, i + 1)
ax.set_title("Plot #%i" % i)
---------------------------------------------
---------------------------------------------
fig.subplots_adjust(wspace=0.3, hspace=0.3)
fig
---------------------------------------------
---------------------------------------------
x = np.linspace(0, 10, 1000)
for i in range(6):
fig.axes[i].plot(x, np.sin(i * x))
fig
---------------------------------------------
---------------------------------------------
---------------------------------------------
Matplotlib Tutorial
http://jakevdp.github.io/mpl_tutorial/index.html
1. Basic Plotting with Pylab
http://jakevdp.github.io/mpl_tutorial/tutorial_pages/tut1.html
2. Object Oriented Interface
http://jakevdp.github.io/mpl_tutorial/tutorial_pages/tut2.html
3. Various Plotting Examples
http://jakevdp.github.io/mpl_tutorial/tutorial_pages/tut3.html
4. Text and Annotation
http://jakevdp.github.io/mpl_tutorial/tutorial_pages/tut4.html
5. 3D Plotting
http://jakevdp.github.io/mpl_tutorial/tutorial_pages/tut5.html
6. Animations
http://jakevdp.github.io/mpl_tutorial/tutorial_pages/tut6.html
No hay comentarios:
Publicar un comentario