Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
RositaNimalin authored Aug 11, 2020
1 parent db60f51 commit 5223151
Showing 1 changed file with 118 additions and 0 deletions.
118 changes: 118 additions & 0 deletions Animation plot.ipynb
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 5223151

Please sign in to comment.