diff --git a/ejercicios-clase-03-01-datos.ipynb b/ejercicios-clase-03-01-datos.ipynb index 412c453badee4904d524e18163b1eec4b3cf151f..9e712c3516bad98c5c0f60ef8f654bfc4509cf5c 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" ] }, {