diff --git a/Animation plot.ipynb b/Animation plot.ipynb new file mode 100644 index 0000000..8f7baf7 --- /dev/null +++ b/Animation plot.ipynb @@ -0,0 +1,118 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Animation Plot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.animation as animation\n", + "\n", + "\n", + "def update(num, data, line):\n", + " line.set_data(data[...,:num])\n", + " return line," + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig1 = plt.figure()\n", + "\n", + "\n", + "x = np.arange(1,26)\n", + "y = np.arange(1,26)\n", + "data = np.vstack((x,y)) #stacking two arrays into one which is passed as argument for update_line function\n", + "\n", + "\n", + "l, = plt.plot([],[])\n", + "print(type(l))\n", + "plt.xlim(1, 26)\n", + "plt.ylim(1,26)\n", + "\n", + "line_ani = animation.FuncAnimation(fig1, update, 25, fargs=(data, l),\n", + " interval=50, blit=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "line_ani.save('lines.gif') # saves the animated plot to gif" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### HeatMap" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import seaborn as sns\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "flights = sns.load_dataset(\"flights\")\n", + "\n", + "flights = flights.pivot(\"month\", \"year\", \"passengers\")\n", + "plt.figure(figsize = (80,80))\n", + "sns.heatmap(flights, cmap = 'icefire_r', cbar = False, xticklabels=False, yticklabels = False)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.4" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}