{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<!DOCTYPE html>\n",
    "<html>\n",
    "<body>\n",
    "<div align=\"center\">\n",
    "<h3>Prepared by Asif Bhat</h3>\n",
    "    \n",
    "<h1>Data Visualization With Matplotlib</h1>\n",
    "\n",
    "<h3>Follow Me on - <a href=\"https://www.linkedin.com/in/asif-bhat/\">LinkedIn</a>&nbsp; <a href=\"https://mobile.twitter.com/_asifbhat_\">Twitter</a>&nbsp; <a href=\"https://www.instagram.com/datasciencescoop/?hl=en\">Instagram</a>&nbsp; <a href=\"https://www.facebook.com/datasciencescoop/\">Facebook</a></h3>\n",
    "</div>\n",
    "\n",
    "</div>\n",
    "</body>\n",
    "</html>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib as mpl\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Area Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 331,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 33068 characters]\n",
      "text/plain": [
       "<Figure size 1152x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = np.arange(1,31)\n",
    "y = np.random.normal(10,11,size=30)\n",
    "y = np.square(y)\n",
    "plt.figure(figsize=(16,6))\n",
    "plt.plot(x,y)\n",
    "plt.fill_between(x, y)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Changing Fill Color"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 334,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 44844 characters]\n",
      "text/plain": [
       "<Figure size 1152x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = np.arange(1,31)\n",
    "y = np.random.normal(10,11,size=30)\n",
    "y = np.square(y)\n",
    "plt.figure(figsize=(16,6))\n",
    "\n",
    "plt.fill_between( x, y, color=\"#baf1a1\")  # #Changing Fill color\n",
    "plt.plot(x, y, color='#7fcd91') # Color on edges\n",
    " \n",
    "plt.title(\"$ Area $  $ chart $\" , fontsize = 16)\n",
    "plt.xlabel(\"$X$\" , fontsize = 16)\n",
    "plt.ylabel(\"$Y$\" , fontsize = 16)\n",
    "\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Changing Fill Color and its transperancy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 336,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 59012 characters]\n",
      "text/plain": [
       "<Figure size 1152x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = np.arange(1,31)\n",
    "y = np.random.normal(10,11,size=30)\n",
    "y = np.square(y)\n",
    "plt.figure(figsize=(16,6))\n",
    "\n",
    "plt.fill_between( x, y, color=\"#C8D700\" , alpha = 0.3) # Changing transperancy using Alpha parameter\n",
    "plt.plot(x, y, color='#36BD00')\n",
    " \n",
    "plt.title(\"$ Area $  $ chart $\" , fontsize = 16)\n",
    "plt.xlabel(\"$X$\" , fontsize = 16)\n",
    "plt.ylabel(\"$Y$\" , fontsize = 16)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 338,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 52000 characters]\n",
      "text/plain": [
       "<Figure size 1152x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 46208 characters]\n",
      "text/plain": [
       "<Figure size 1152x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = np.arange(1,51)\n",
    "y = np.random.normal(1,5,size=50)\n",
    "y = np.square(y)\n",
    "\n",
    "plt.figure(figsize=(16,6))\n",
    "plt.fill_between( x, y, color=\"#5ac8fa\", alpha=0.4)\n",
    "plt.plot(x, y, color=\"blue\", alpha=0.6) # Bold line on edges\n",
    "plt.title(\"$ Area $  $ chart $\" , fontsize = 16)\n",
    "plt.xlabel(\"$X$\" , fontsize = 16)\n",
    "plt.ylabel(\"$Y$\" , fontsize = 16)\n",
    "plt.show()\n",
    "\n",
    "plt.figure(figsize=(16,6))\n",
    "plt.fill_between( x, y, color=\"#5ac8fa\", alpha=0.4)\n",
    "plt.plot(x, y, color=\"blue\", alpha=0.2) # Less stronger line on edges\n",
    "plt.title(\"$ Area $  $ chart $\" , fontsize = 14)\n",
    "plt.xlabel(\"$X$\" , fontsize = 14)\n",
    "plt.ylabel(\"$Y$\" , fontsize = 14)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Stacked Area plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 339,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23824 characters]\n",
      "text/plain": [
       "<Figure size 576x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x=np.arange(1,6)\n",
    "y1 =  np.array([1,5,9,13,17])\n",
    "y2 = np.array([2,6,10,14,16])\n",
    "y3 = np.array([3,7,11,15,19])\n",
    "y4 = np.array([4,8,12,16,20])\n",
    "\n",
    "plt.figure(figsize=(8,6))\n",
    "plt.stackplot(x,y1,y2,y3,y4, labels=['Y1','Y2','Y3','Y4'])\n",
    "plt.legend(loc='upper left')\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 340,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23824 characters]\n",
      "text/plain": [
       "<Figure size 576x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x=np.arange(1,6)\n",
    "y=[ [1,5,9,13,17], [2,6,10,14,16], [3,7,11,15,19] , [4,8,12,16,20] ]\n",
    "plt.figure(figsize=(8,6))\n",
    "plt.stackplot(x,y , labels=['Y1','Y2','Y3','Y4'])\n",
    "plt.legend(loc='upper left')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 341,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 38652 characters]\n",
      "text/plain": [
       "<Figure size 720x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x=np.arange(1,7)\n",
    "y=[ [1,5,9,3,17,1], [2,6,10,4,16,2], [3,7,11,5,19,1] , [4,8,12,6,20,2] ]\n",
    "plt.figure(figsize=(10,6))\n",
    "plt.stackplot(x,y , labels=['Y1','Y2','Y3','Y4'])\n",
    "plt.legend(loc='upper left')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Changing Fill Color and its transperancy in Stacked Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 342,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 38628 characters]\n",
      "text/plain": [
       "<Figure size 792x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 37940 characters]\n",
      "text/plain": [
       "<Figure size 792x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 35980 characters]\n",
      "text/plain": [
       "<Figure size 792x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x=np.arange(1,7)\n",
    "y=[ [1,5,9,3,17,1], [2,6,10,4,16,2], [3,7,11,5,19,1] , [4,8,12,6,20,2] ]\n",
    "\n",
    "plt.figure(figsize=(11,6))\n",
    "plt.stackplot(x,y , labels=['Y1','Y2','Y3','Y4'] , colors= [\"#00b159\" , \"#ffc425\", \"#f37735\", \"#ff3b30\"])\n",
    "plt.legend(loc='upper left')\n",
    "plt.show()\n",
    "\n",
    "plt.figure(figsize=(11,6))\n",
    "plt.stackplot(x,y, labels=['Y1','Y2','Y3','Y4'], colors= [\"#00b159\" , \"#ffc425\", \"#f37735\", \"#ff3b30\"], alpha=0.7 )\n",
    "plt.legend(loc='upper left')\n",
    "plt.show()\n",
    "\n",
    "plt.figure(figsize=(11,6))\n",
    "plt.stackplot(x,y, labels=['Y1','Y2','Y3','Y4'], colors= [\"#00b159\" , \"#ffc425\", \"#f37735\", \"#ff3b30\"], alpha=0.5 )\n",
    "plt.legend(loc='upper left')\n",
    "plt.show()"
   ]
  }
 ],
 "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.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
