From 9c8ce75e4f75876dd1de40237a771673d5397f9d Mon Sep 17 00:00:00 2001 From: Christan Solis Calero <solisc@jupyterMiLAB> Date: Wed, 10 Feb 2021 22:52:35 -0500 Subject: [PATCH] =?UTF-8?q?Actualizaci=C3=B3n=20de=20la=20tarea=2003?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ejercicios-clase-03-01-datos.ipynb | 60 +++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/ejercicios-clase-03-01-datos.ipynb b/ejercicios-clase-03-01-datos.ipynb index 412c453..9e712c3 100644 --- a/ejercicios-clase-03-01-datos.ipynb +++ b/ejercicios-clase-03-01-datos.ipynb @@ -187,8 +187,22 @@ "source": [ "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import matplotlib.animation as animation\n", - "\n", + "import matplotlib.animation as animation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Generando una función que permita generar imagenes a medida que se adiciona progresivamente la información de cada estrella" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "def salvar_figura(x,y,co,z,n):\n", " fig = plt.figure(figsize=(12,8))\n", " scat = plt.scatter(x, y,\n", @@ -208,9 +222,38 @@ " plt.yticks(fontsize=10, fontweight='bold')\n", " plt.xlim(14000, 3000)\n", " plt.ylim(0.00001, 10000000)\n", - " plt.ioff() #turning off Interactive Mode for generating figures\n", - " plt.savefig(\"Animation\"+str(n)+\".png\", format=\"png\")\n", + " \n", + " #Adding the Axes object ax: It is a container that holds the axes, the ticks, the labels, the plot, the legend, etc.\n", + " ax = plt.axes()\n", "\n", + " #Method for generate lines only in X and Y axis\n", + " ax.spines['top'].set_visible(False)\n", + " ax.spines['right'].set_visible(False)\n", + "\n", + " #Modifying ticks of X axis to eliminate scientific notation \n", + " from matplotlib.ticker import FuncFormatter\n", + " def Wscientific(x, pos):\n", + " return '%1i' % (x)\n", + " formatter = FuncFormatter(Wscientific)\n", + " ax.xaxis.set_major_formatter(formatter)\n", + " plt.setp(ax.get_xminorticklabels(), visible=False)\n", + " \n", + " plt.savefig(\"Animation\"+str(n)+\".png\", format=\"png\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Introduciendo la data de las estrellas progresivamente para que se generen las imagenes" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "VectX=[]\n", "VectY=[]\n", "VectC=[]\n", @@ -223,7 +266,14 @@ " VectZ.append(radius[n])\n", " salvar_figura(VectX,VectY,VectC,VectZ,n)\n", " n=n+1\n", - "plt.show()\n" + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Generando la animación a partir de la información de las imagenes" ] }, { -- GitLab