%matplotlib inline import numpy as np import matplotlib.pyplot as plt from IPython.display import HTML HTML('') HTML('') plt.plot([0, 0.1, 0.2, 0.5,0.6], [1, -1, 0, 3, -1]) def f(x): return np.exp(-x ** 2) x = np.linspace(-1, 5, num=30) plt.plot(x, f(x), label="Función f(x)") plt.xlabel("Eje $x$") plt.ylabel("$f(x)$") plt.legend() plt.title("Función $f(x)$") plt.plot(x, f(x), 'ro') plt.plot(x, 1 - f(x), 'g--') plt.plot(x, f(x), color='red', linestyle='', marker='o') plt.plot(x, 1 - f(x), c='g', ls='--') N = 100 x = np.random.randn(N) y = np.random.randn(N) plt.scatter(x, y) s = 50 + 50 * np.random.randn(N) c = np.random.randn(N) plt.scatter(x, y, s=s, c=c, cmap=plt.cm.Blues) plt.colorbar() plt.scatter(x, y, s=s, c=c, cmap=plt.cm.Oranges) plt.colorbar() def f(x, y): return np.cos(x) + np.sin(y) ** 2 x = np.linspace(-2, 2) y = np.linspace(-2, 2) xx, yy = np.meshgrid(x, y) plt.contour(xx, yy, f(xx, yy)) plt.colorbar() zz = f(xx, yy) plt.contourf(xx, yy, zz, np.linspace(-0.5, 2.0)) plt.colorbar() x f(x) fig, axes = plt.subplots() axes.plot(x, f(x), 'ro', label="Función F(x)") axes.set_xlim(-2, 4) axes.set_ylim(-1, 2) fig.savefig("grafica1.png") fig, axes = plt.subplots(1, 2, sharey=True) axes[0].plot(x, f(x), color="blue") axes[0].set_xlabel("Eje x") axes[1].plot(x, -f(x), 'r') axes[1].set_xlabel("Eje x de la gráfica derecha") x = np.random.randn(100) y = np.random.randn(100) s = 200 * np.random.randn(100) c = np.random.randn(100) plt.scatter(x, y, s, c, cmap=plt.cm.BrBG_r) x = np.linspace(-2, 2) y = np.linspace(-2, 2) xx, yy = np.meshgrid(x, y) def g(x, y): return np.cos(x) + np.sin(y) ** 2 zz = g(xx, yy) fig, axes = plt.subplots() axes.contourf(xx, yy, zz, np.linspace(-1, 1), cmap=plt.cm.autumn) !cat temperaturas.csv datos = np.loadtxt("temperaturas.csv", usecols=(1, 2, 3), skiprows=1, delimiter=',') fig, axes = plt.subplots() x = np.arange(len(datos[:, 1])) temp_media = (datos[:, 1] + datos[:, 2]) / 2 axes.plot(x, datos[:, 1], 'r') axes.plot(x, datos[:, 2], 'b') axes.plot(x, temp_media, 'k')