{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"#### The below code is automation of some useful graphs in matplotlib which we use regularly.\n#### After Executing this code you need to enter name/path of your csv file to which you want to do plotting, next you need to select a plot and enter column names by reading instructions. You can also give your customized color or css color to your plot.If you want to contine after one plot enter y if not enter n and rerun the code and enter another filename/filepath\n#### Plots involved in this are:\n### 1.Line PLot\n   #### one scatter plotting\n   #### two scatter plottings\n   #### morethan two scatter plottings\n### 2.Bar Plot\n   #### Basic barplot\n   #### horizontal barplot\n   #### vertical stacked barplot\n   #### horizontal stacked barplot\n   #### Press 5 for grouped barplot\n### 3.Scatter Plot\n   #### one scatter plotting\n   #### two scatter plottings\n   #### morethan two scatter plottings\n### 4.Histogram PLot\n   #### Basic Histogram Plot\n   #### more than 1 Histogram Plot\n   #### Multiple histogram plots in same grid\n   #### cumulative distribution histogram plot\n### 5.Pie Plot\n   #### Basic pie plot\n   #### Multiple pie plot\n   #### Exploding a slice of from a pie plot\n   #### Exploding more than one slice from a pie plot\n### 6.Area Plot\n   #### basic area plot\n   #### stacked area plot\n### 7.Donut Plot\n   #### Basic donut plot\n   #### Multiple donut plot\n   #### Exploding a slice of from a donut plot\n   #### Exploding more than one slice from a donut plot\n### 8.Stem Plot\n### 9.Box Plot\n   #### single column box plot\n   #### morethan one  column box plot\n### 10.Violin Plot\n   #### single column violin plot\n   #### morethan one violon box plot","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib as mpl\nimport matplotlib.pyplot as plt\n%matplotlib inline","metadata":{"execution":{"iopub.status.busy":"2021-11-08T04:07:21.422732Z","iopub.execute_input":"2021-11-08T04:07:21.423467Z","iopub.status.idle":"2021-11-08T04:07:21.448224Z","shell.execute_reply.started":"2021-11-08T04:07:21.423333Z","shell.execute_reply":"2021-11-08T04:07:21.447570Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Graph Styling\nplt.style.use('seaborn-darkgrid')","metadata":{"execution":{"iopub.status.busy":"2021-11-08T04:07:56.090253Z","iopub.execute_input":"2021-11-08T04:07:56.091066Z","iopub.status.idle":"2021-11-08T04:07:56.094884Z","shell.execute_reply.started":"2021-11-08T04:07:56.091023Z","shell.execute_reply":"2021-11-08T04:07:56.094084Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def line_plot(df):\n    n = int(input('Press 1 for Single line chart\\n' \n                  'Press 2 for Multi Line chart:'))\n    if n == 1:\n        print('select any column from', df.columns)\n        x = input(\"Enter X-axis column name:\")\n        y = input(\"Enter Y- axis column name:\")\n        c = input('Enter a color which is accepted by mathplotlib:')\n        plt.plot(df[x],df[y],color = c)\n        plt.xlabel(x) \n        plt.ylabel(y)\n        plt.title('LINE PLOT')\n        plt.show()\n    elif n==2:\n        print('select any column from', df.columns)\n        x = input(\"Enter column name in x axis:\")\n        t = int(input(\"Enter number of columns in Y axis:\"))\n        y = []\n        j = []\n        colors=[]\n        for i in range(t):\n            d = input(\"Enter column name in y axis:\")\n            y.append(d)\n            c = input('Enter a color which is accepted by mathplotlib:')\n            colors.append(c)\n        plt.figure(figsize=(12,5)) # Setting the figure size\n        ax = plt.axes()\n        ax.set_facecolor(\"darkgrey\") # Setting the background color by using Hex code\n        for i in range(len(y)):\n            plt.plot(df[x],df[y[i]],colors[i],label = y[i])\n        plt.xlabel(x) \n        plt.ylabel(y)\n        plt.legend(loc='upper right', fontsize='large',bbox_to_anchor=(1.2, 1.0))\n        plt.title('LINE PLOT')\n        plt.show()\n    else:\n        print(\"Incorrect option\")\n        \n        \ndef bar_plot(df):\n    n = int(input('Press 1 for Basic barplot:\\n'\n                  'Press 2 for horizontal barplot:\\n'\n                  'Press 3 for vertical stacked barplot:\\n'\n                  'Press 4 for horizontal stacked barplot:\\n'\n                  'Press 5 for grouped barplot:\\n'))\n    if n == 1:\n        print('select any column from', df.columns)\n        x = input(\"Enter X-axis column name:\")\n        y = input(\"Enter Y-axis column name:\")\n        plt.figure(figsize=(8,5)) # Setting the figure size\n        ax = plt.axes()\n        ax.set_facecolor(\"#ECF0F1\")\n        c = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n        plt.bar(df[x],df[y],color = c)\n        plt.xlabel(x)\n        plt.ylabel(y)\n        for x,y in zip(df[x],df[y]):\n            plt.text(x, y+0.05, '%f' % y, ha='center' , va= 'bottom')\n            plt.plot()\n        plt.title('BAR PLOT')\n        plt.show()\n    elif n==2:\n        print('select any column from', df.columns)\n        x = input(\"Enter X-axis column name:\")\n        y = input(\"Enter Y-axis column name:\")\n        plt.figure(figsize=(8,5)) # Setting the figure size\n        ax = plt.axes()\n        ax.set_facecolor(\"#ECF0F1\")\n        c = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n        plt.barh(df[x],df[y],color =c)\n        plt.xlabel(x)\n        plt.ylabel(y)\n        for index, value in enumerate(df[y]):\n            plt.text(value, index, str(value))\n            plt.plot()\n        plt.show()\n    elif n==3:\n        print('select any column from', df.columns)\n        x = input(\"Enter column name in x axis:\")\n        t = int(input(\"Enter number of columns in Y axis:\"))\n        h = []\n        for i in df[x]:\n            h.append(i)\n        y = []\n        b=[]\n        l=[]\n        colors = []\n        for i in range(t):\n            d = input(\"Enter column name in y axis:\")\n            c = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n            y.append(d)\n            colors.append(c)\n            p = []\n            for i in df[d]:\n                p.append(i)\n            l.append(p)\n        k = l[0]\n        b.append(k)\n        for i in range(1,t-1):\n            b.append(k)\n            k = k + l[i]\n        plt.figure(figsize=(5,7)) # Setting the figure size\n        ax = plt.axes()\n        ax.set_facecolor(\"#ECF0F1\")\n        plt.bar(h,df[y[0]],label = y[0],color = colors[0])\n        for i in range(1,len(y)):\n            plt.bar(h,df[y[i]],label = y[i],bottom = b[i-1],color = colors[i])\n        plt.xlabel(x)\n        plt.ylabel(y)\n        plt.title ('$Bar $ $ Chart$')\n        if len(y) == 2:\n            for x,y in zip(h,l[0]):\n                plt.text(x, y, '%f' % y, ha='center' , va= 'bottom')\n            for i in range(1,t):\n                for x,y,z in zip(h,l[i],l[i-1]):\n                    plt.text(x, y+z, '%f' % y, ha='center' , va= 'bottom')\n        plt.legend(loc='center left', bbox_to_anchor=(1, 0.5))\n        plt.show()\n    elif n==4:\n        print('select any column from', df.columns)\n        y = input(\"Enter column name in y axis:\")\n        h = []\n        l=[]\n        for i in df[y]:\n            h.append(i)\n        t = int(input(\"Enter number of columns in X axis:\"))\n        x = []\n        b=[]\n        colors = []\n        for i in range(t):\n            d = input(\"Enter column name in X axis:\")\n            c = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n            x.append(d)\n            colors.append(c)\n            p = []\n            for i in df[d]:\n                p.append(i)\n            l.append(p)\n        k = x[0]\n        b.append(k)\n        for i in range(1,t-1):\n            b.append(k)\n            k = k + x[i+1]\n        plt.figure(figsize=(8,5)) # Setting the figure size\n        ax = plt.axes()\n        ax.set_facecolor(\"#ECF0F1\")\n        plt.barh(df[y],df[x[0]],label = x[0],color = colors[0])\n        for i in range(1,len(x)):\n            plt.barh(df[y],df[x[i]],label = x[i],left = df[b[i-1]],color = colors[i])\n        plt.xlabel(x)\n        plt.ylabel(y)\n        if len(x) == 2:\n            for x,y in zip(l[0],h):\n                plt.text(x-10, y, '%f' % x, ha='center' , va= 'bottom')    \n            for i in range(1,t):\n                for x,y,z in zip(l[i],h,l[i-1]):\n                    plt.text(x+z-10, y, '%f' % x, ha='center' , va= 'bottom')\n        plt.title ('$Bar $ $ Chart$')\n        plt.legend(loc='center left', bbox_to_anchor=(1, 0.5))\n        plt.show()\n    elif n==5:\n        print('select any column from', df.columns)\n        # Displaying values at the top of the Grouped Bar Chart using plt.text()\n        plt.figure(figsize=(7,9))\n        barWidth = 0.25 # set width of bar\n        # set height of bar\n        x = input(\"Enter column name in x axis:\")\n        h = []\n        l = []\n        for i in df[x]:\n            h.append(i)\n        t = int(input(\"Enter number of columns in Y axis:\"))\n        y = []\n        colors = []\n        for i in range(t):\n            d = input(\"Enter column name in y axis:\")\n            c = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n            y.append(d)\n            colors.append(c)\n            p = []\n            for i in df[d]:\n                p.append(i)\n            l.append(p)\n        pos = []\n        pos.append(np.arange(len(df[y[0]])))\n        for i in range(1,t):\n            m = [x + barWidth for x in pos[i-1]]\n            pos.append(m)\n        for i in range(t):\n            plt.bar(pos[i], df[y[i]], color= colors[i], width=barWidth, label=y[i])\n\n        # Add xticks on the middle of the group bars\n        plt.xlabel('X-axis', fontweight='bold')\n        plt.ylabel('Y-axis', fontweight='bold')\n        plt.xticks([i + barWidth for i in range(len(df[y[0]]))], h)\n        \n        for i in range(t):\n            for x,y in zip(pos[i],l[i]):\n                plt.text(x, y, '%f' % y, ha='center' , va= 'bottom')\n\n        plt.title ('$Grouped $  $ Bar $  $ Chart$')\n\n        # Create legend & Show graphic\n        plt.legend(loc='center left', bbox_to_anchor=(1, 0.5))\n        plt.show()\n\ndef scatter_plot(df):\n    n = int(input('Press 1 for one scatter plotting:\\n'\n                  'Press 2 for two scatter plottings:\\n'\n                  'Press 3 for morethan two scatter plottings'))\n    if n == 1:\n        print('select any column from', df.columns)\n        x = input(\"Enter X- axis column name:\")\n        y = input(\"Enter Y-axis column name:\")\n        c = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n        plt.scatter(df[x],df[y] ,color = c)\n        plt.xlabel(x , fontsize = 12)\n        plt.ylabel(y , fontsize = 12)\n        plt.title ('Scatter Graph')\n        plt.show()\n        \n    if n == 2:\n        print('select any column from', df.columns)\n        x = input(\"Enter X- axis column name:\")\n        y = input(\"Enter Y-axis column name:\")\n        y1 = input(\"Enter another Y- axis column name:\")\n        c1 = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n        c2 = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n        plt.scatter(df[x],df[y] ,label = y,marker='o' , color = c1)\n        plt.xlabel(x , fontsize = 12)\n        plt.ylabel(y , fontsize = 12)\n        plt.title ('Scatter Graph')\n        plt.show()\n        plt.scatter(df[x],df[y1] ,label = y1,marker='v',color =c2)\n        plt.xlabel(x , fontsize = 12)\n        plt.ylabel(y , fontsize = 12)\n        plt.show()\n        plt.scatter(df[x],df[y] ,label = y,marker='o' , color = c1)\n        plt.scatter(df[x],df[y1] ,label = y1,marker='v',color =c2)\n        plt.xlabel(x , fontsize = 12)\n        z = y + y1\n        plt.ylabel(z, fontsize = 12)\n        plt.title ('Scatter Graph')\n        plt.legend(loc='center left', bbox_to_anchor=(1, 0.5))\n        plt.show()\n    if n == 3:\n        print('select any column from', df.columns)\n        p = int(input(\"Enter number of plottings u want:\"))\n        y = []\n        colors = []\n        markers = ['o','v','s','p','*']\n        x = input(\"Enter X- axis column name:\")\n        for i in range(p):\n            b = input(\"Enter Y-axis column name:\")\n            y.append(b)\n        colors = []\n        for i in range(p):\n            c = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n            colors.append(c)\n        for i in range(p):\n            plt.scatter(df[x],df[y[i]],color =colors[i])\n            plt.xlabel(x , fontsize = 12)\n            plt.ylabel(y[i] , fontsize = 12)\n            plt.title ('Scatter Graph')\n            plt.show()\n        for i in range(p):\n            plt.scatter(df[x],df[y[i]] ,marker= markers[i],label = y[i],color =colors[i])\n            plt.title ('Scatter Graph')\n        plt.xlabel(x , fontsize = 12)\n        plt.ylabel(y , fontsize = 12)\n        plt.title ('Scatter Graph')\n        plt.legend(loc='center left', bbox_to_anchor=(1, 0.5))\n        plt.show()\n\n        \ndef histogram_plot(df):\n    n = int(input('Press 1 for Basic Histogram Plot\\n'\n                  'Press 2 to plot more than 1 Histogram Plot\\n'\n                  'Press 3 to plot Multiple histogram plots in same grid\\n'\n                  'Press 4 to plot a cumulative distribution histogram plot'))\n    if n==1:\n        print('select any column from', df.columns)\n        x = input('Enter column name:')\n        b = int(input('Enter no.of bins:'))\n        c = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n        e = input('Enter Edge color')\n        plt.hist(df[x], bins=b, color=c,edgecolor=e)\n        plt.gca().set(title='Histogram', ylabel='Frequency')\n        plt.show()\n    if n == 2:\n        print('select any column from', df.columns)\n        num = int(input('Enter number of plots u need'))\n        for i in range(num):\n            x = input('Enter column name:')\n            b = int(input('Enter no.of bins:'))\n            c = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n            e = input('Enter Edge color')\n            plt.hist(df[x], bins=b, color=c,edgecolor=e)\n            plt.gca().set(title='Histogram', ylabel='Frequency')\n            plt.show()\n    if n==3:\n        print('select any column from', df.columns)\n        plt.figure(figsize=(8,11))\n        num = int(input('Enter number of plots u need'))\n        x = []\n        b = []\n        c = []\n        e = []\n        for i in range(num):\n            r = input('Enter column name:')\n            x.append(r)\n            bi = int(input('Enter no.of bins:'))\n            b.append(bi)\n            co = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n            c.append(co)\n            ed = input('Enter Edge color')\n            e.append(ed)\n        for i in range(num):\n            plt.hist(df[x[i]], bins=b[i], color=c[i] , edgecolor =e[i], alpha=0.6)\n        plt.show()\n    if n==4:\n        print('select any column from', df.columns)\n        plt.figure(figsize=(10,8))\n        x = input('Enter column name:')\n        b = int(input('Enter no.of bins:'))\n        c = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n        plt.hist(df[x], bins=b ,color=c , edgecolor=\"#639a67\",cumulative=True)\n        plt.gca().set(title='Histogram', ylabel='Frequency')\n        plt.show()\n        \n        \n\ndef pie_charts(df):\n    n = int(input('Press 1 for Basic pie plot\\n'\n                  'Press 2 for Multiple pie plot\\n'\n                  'Press 3 for Exploding a slice of from a pie plot\\n'\n                  'Press 4 for Exploding more than one slice from a pie plot'))\n    if n==1:\n        print('select any column from', df.columns)\n        plt.figure(figsize=(8,8))\n        x = input('Enter column name:')\n        l = input('Enter its label')\n        colors = ['#8BC34A','#D4E157','#FFB300','#FF7043','blue','green','magenta','red']\n        plt.pie (df[x] , labels= df[l] , colors= colors , startangle=45 , shadow='true', autopct='%1.1f%%', explode=[0,0 , 0 , 0])\n        plt.show()\n    if n==2:\n        print('select any column from', df.columns)\n        l = []\n        t = int(input('Enter how many pieplots u need:'))\n        r = int(input('Enter how many rows u need in subplot'))\n        c = int(input('Enter how many columns u need in subplot'))\n        if r*c != t:\n            print(\"Invalid rows and columns\")\n        else:\n            x = input('Enter column name:')\n            colors = ['#8BC34A','#D4E157','#FFB300','#FF7043','blue','green','magenta','red']\n            for i in range(t):\n                fig = plt.figure(figsize=(20,13))\n                la = input('Enter its Label')\n                l.append(la)\n            for i in range(t):\n                plt.subplot(r,c,i+1)\n                plt.pie (df[x] , labels= df[l[i]] , colors= colors[:df[x].count()] , startangle=45 ,shadow =True, autopct='%1.1f%%')\n            plt.show()\n    if n==3:\n        print('select any column from', df.columns)\n        plt.figure(figsize=(8,8))\n        x = input('Enter column name:')\n        l = input('Enter its label')\n        colors = ['#8BC34A','#D4E157','#FFB300','#FF7043','blue','green','magenta','red']\n        e = []\n        for i in range(len(df[l])):\n            e.append(0)\n        f = int(input('Enter which slice u want to explode:'))\n        for i in range(1,len(e)+1):\n            if i == f:\n                e[i-1] = 0.1\n        plt.pie (df[x] , labels= df[l] , colors= colors , startangle=45 , shadow='true', autopct='%1.1f%%', explode=e)\n        plt.show()\n    if n==4:\n        print('select any column from', df.columns)\n        plt.figure(figsize=(8,8))\n        x = input('Enter column name:')\n        l = input('Enter its label')\n        colors = ['#8BC34A','#D4E157','#FFB300','#FF7043','blue','green','magenta','red']\n        e = []\n        for i in range(len(df[l])):\n            e.append(0)\n        f = int(input('Enter how many slices u want to explode:'))\n        m = []\n        for i in range(f):\n            v = int(input('Enter which slice u want to explode:'))\n            m.append(v)\n        for i in range(1,len(m)+1):\n            for j in range(1,len(e)+1):\n                if m[i-1] == j:\n                    e[j-1] = 0.1\n        print(e)\n        plt.pie (df[x] , labels= df[l] , colors= colors , startangle=45 , shadow='true', autopct='%1.1f%%', explode=e)\n        plt.show()\n\n        \ndef area_plot(df):\n    n = int(input('Press 1 for basic area plot\\n'\n                  'Press 2 for stacked area plot'))\n    if n == 1:\n        print('select any column from', df.columns)\n        x = input('Enter X-axis column name:')\n        y = input('Enter Y-axis column name:')\n        plt.figure(figsize=(16,6))\n        print('Enter a color you want in between:')\n        c = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n        plt.fill_between( df[x], df[y], color=c, alpha = 0.3) # Changing transperancy using Alpha parameter\n        print('Which color u want on edges:')\n        c1 = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n        plt.plot(df[x], df[y], color=c1)\n        plt.title(\"$ Area $  $ chart $\" , fontsize = 16)\n        plt.xlabel(x , fontsize = 16)\n        plt.ylabel(y , fontsize = 16)\n        plt.show()\n    if n==2:\n        print('select any column from', df.columns)\n        x = input('Enter X-axis column name:')\n        t = int(input('Enter number of Y-axis columns u need:'))\n        l= []\n        y = []\n        color = []\n        for i in range(t):\n            col = input('Enter Y-axis column name:')\n            l.append(col)\n            y.append(df[col])\n        plt.figure(figsize=(8,6))\n        for i in range(t):\n            c = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n            color.append(c)\n        a = float(input('Select your transparency value:'))\n        plt.stackplot(df[x],y,labels=l,colors = color,alpha = a )\n        plt.legend(loc='upper left')\n        plt.xlabel(x , fontsize = 16)\n        plt.show()\n\ndef donut_plots(df):\n    n = int(input('Press 1 for Basic donut plot\\n'\n                  'Press 2 for Multiple donut plot\\n'\n                  'Press 3 for Exploding a slice of from a donut plot\\n'\n                  'Press 4 for Exploding more than one slice from a donut plot'))\n    if n==1:\n        print('select any column from', df.columns)\n        plt.figure(figsize=(8,8))\n        x = input('Enter column name:')\n        l = input('Enter its label')\n        colors = ['#8BC34A','#D4E157','#FFB300','#FF7043','blue','green','magenta','red']\n        plt.pie (df[x] , labels= df[l] , colors= colors , startangle=45 , shadow='true', autopct='%1.1f%%', explode=[0,0 , 0 , 0])\n        my_circle=plt.Circle( (0,0), 0.7, color='white') # Adding circle at the centre\n        p=plt.gcf()\n        p.gca().add_artist(my_circle)\n        plt.show()\n    if n==2:\n        print('select any column from', df.columns)\n        l = []\n        t = int(input('Enter how many donut plots u need:'))\n        r = int(input('Enter how many rows u need in subplot'))\n        c = int(input('Enter how many columns u need i n subplot'))\n        if r*c != t:\n            print(\"Invalid rows and columns\")\n        else:\n            x = input('Enter column name:')\n            colors = ['#8BC34A','#D4E157','#FFB300','#FF7043','blue','green','magenta','red']\n            for i in range(t):\n                fig = plt.figure(figsize=(20,13))\n                la = input('Enter its Label')\n                l.append(la)\n            for i in range(t):\n                plt.subplot(r,c,i+1)\n                plt.pie (df[x] , labels= df[l[i]] , colors= colors[:df[x].count()] , startangle=45 ,shadow =True, autopct='%1.1f%%')\n                my_circle=plt.Circle( (0,0), 0.7, color='white') # Adding circle at the centre\n                p=plt.gcf()\n                p.gca().add_artist(my_circle)\n            plt.show()\n    if n==3:\n        print('select any column from', df.columns)\n        plt.figure(figsize=(8,8))\n        x = input('Enter column name:')\n        l = input('Enter its label')\n        colors = ['#8BC34A','#D4E157','#FFB300','#FF7043','blue','green','magenta','red']\n        e = []\n        for i in range(len(df[l])):\n            e.append(0)\n        f = int(input('Enter which slice u want to explode:'))\n        for i in range(1,len(e)+1):\n            if i == f:\n                e[i-1] = 0.1\n        print(e)\n        plt.pie (df[x] , labels= df[l] , colors= colors , startangle=45 , shadow='true', autopct='%1.1f%%', explode=e)\n        my_circle=plt.Circle( (0,0), 0.7, color='white') # Adding circle at the centre\n        p=plt.gcf()\n        p.gca().add_artist(my_circle)\n        plt.show()\n    if n==4:\n        print('select any column from', df.columns)\n        plt.figure(figsize=(8,8))\n        x = input('Enter column name:')\n        l = input('Enter its label')\n        colors = ['#8BC34A','#D4E157','#FFB300','#FF7043','blue','green','magenta','red']\n        e = []\n        for i in range(len(df[l])):\n            e.append(0)\n        f = int(input('Enter how many slices u want to explode:'))\n        m = []\n        for i in range(f):\n            v = int(input('Enter which slice u want to explode:'))\n            m.append(v)\n        for i in range(1,len(m)+1):\n            for j in range(1,len(e)+1):\n                if m[i-1] == j:\n                    e[j-1] = 0.1\n        print(e)\n        plt.pie (df[x] , labels= df[l] , colors= colors , startangle=45 , shadow='true', autopct='%1.1f%%', explode=e)\n        my_circle=plt.Circle( (0,0), 0.7, color='white') # Adding circle at the centre\n        p=plt.gcf()\n        p.gca().add_artist(my_circle)\n        plt.show()\n\ndef stem_plot(df):\n    print('select any column from', df.columns)\n    x = input('Enter X-axis column name:')\n    y = input('Enter Y-axis column name:')\n    plt.figure(figsize=(8,8))\n    c = input('Enter a color which is accepted by mathplotlib(CSS colors are also accepted):')\n    plt.xlabel(x)\n    plt.ylabel(y)\n    plt.stem(df[x],df[y],linefmt=c)\n    plt.show()\n\ndef box_plot(df):\n    plt.figure(figsize =(10, 7))\n    n = int(input('Press 1 for single column box plot\\n'\n                  'Press 2 for morethan one  column box plot'))\n    if n==1:\n        print('select any column from', df.columns)\n        x = input('Enter column name:')\n        plt.boxplot(df[x])\n        plt.ylabel(x)\n        plt.show()\n    if n==2:\n        print('select any column from', df.columns)\n        d = []\n        x = []\n        e = int(input('Enter how many columns u want:'))\n        for i in range(e):\n            b = input('Enter column name:')\n            x.append(b)\n            d.append(df[b])\n        plt.boxplot(d)\n        plt.ylabel(x)\n        plt.show()\n    \ndef violin_plot(df):\n    plt.figure(figsize =(10, 7))\n    n = int(input('Press 1 for single column violin plot\\n'\n                  'Press 2 for morethan one violon box plot'))\n    if n==1:\n        print('select any column from', df.columns)\n        x = input('Enter column name:')\n        plt.violinplot(df[x])\n        plt.ylabel(x)\n        plt.show()\n    if n==2:\n        print('select any column from', df.columns)\n        d = []\n        x = []\n        e = int(input('Enter how many columns u want:'))\n        for i in range(e):\n            b = input('Enter  column name:')\n            x.append(b)\n            d.append(df[b])\n        plt.violinplot(d)\n        plt.ylabel(x)\n        plt.show()","metadata":{"execution":{"iopub.status.busy":"2021-11-08T04:07:59.683055Z","iopub.execute_input":"2021-11-08T04:07:59.683321Z","iopub.status.idle":"2021-11-08T04:07:59.781663Z","shell.execute_reply.started":"2021-11-08T04:07:59.683292Z","shell.execute_reply":"2021-11-08T04:07:59.781061Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Line,scatter,box,violin plots","metadata":{}},{"cell_type":"code","source":"def matplotlib_visualisation():\n    data = input('Enter the path or file name:')\n    df=pd.read_csv(data)\n    restart = 'y'\n    while restart == 'y':\n        print('1.Line PLot\\n'\n              '2.Bar Plot\\n'\n              '3.Scatter Plot\\n'\n              '4.Histogram PLot\\n'\n              '5.Pie Plot\\n'\n              '6.Area Plot\\n'\n              '7.Donut Plot\\n'\n              '8.Stem Plot\\n'\n              '9.Box Plot\\n'\n              '10.Violin Plot\\n')\n        g = int(input('Select any one plot to plot in matplotlib:'))\n        if g==1:\n            line_plot(df)\n        elif g==2:\n            bar_plot(df)\n        elif g==3:\n            scatter_plot(df)\n        elif g==4:\n            histogram_plot(df)\n        elif g==5:\n            pie_charts(df)\n        elif g==6:\n            area_plot(df)\n        elif g==7:\n            donut_plots(df)\n        elif g==8:\n            stem_plot(df)\n        elif g==9:\n            box_plot(df)\n        elif g==10:\n            violin_plot(df)\n        else:\n            print('Invaild option')\n        q = input('Do you want to continue plotting?(y/n):')\n        if q == 'y':\n            restart = 'y'\n        else:\n            restart = 'n'\nmatplotlib_visualisation()","metadata":{"execution":{"iopub.status.busy":"2021-11-08T04:07:59.998989Z","iopub.execute_input":"2021-11-08T04:07:59.999435Z","iopub.status.idle":"2021-11-08T04:12:21.104832Z","shell.execute_reply.started":"2021-11-08T04:07:59.999390Z","shell.execute_reply":"2021-11-08T04:12:21.103829Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Bar plot","metadata":{}},{"cell_type":"code","source":"def matplotlib_visualisation():\n    data = input('Enter the path or file name:')\n    df=pd.read_csv(data)\n    restart = 'y'\n    while restart == 'y':\n        print('1.Line PLot\\n'\n              '2.Bar Plot\\n'\n              '3.Scatter Plot\\n'\n              '4.Histogram PLot\\n'\n              '5.Pie Plot\\n'\n              '6.Area Plot\\n'\n              '7.Donut Plot\\n'\n              '8.Stem Plot\\n'\n              '9.Box Plot\\n'\n              '10.Violin Plot\\n')\n        g = int(input('Select any one plot to plot in matplotlib:'))\n        if g==1:\n            line_plot(df)\n        elif g==2:\n            bar_plot(df)\n        elif g==3:\n            scatter_plot(df)\n        elif g==4:\n            histogram_plot(df)\n        elif g==5:\n            pie_charts(df)\n        elif g==6:\n            area_plot(df)\n        elif g==7:\n            donut_plots(df)\n        elif g==8:\n            stem_plot(df)\n        elif g==9:\n            box_plot(df)\n        elif g==10:\n            violin_plot(df)\n        else:\n            print('Invaild option')\n        q = input('Do you want to continue plotting?(y/n):')\n        if q == 'y':\n            restart = 'y'\n        else:\n            restart = 'n'\nmatplotlib_visualisation()","metadata":{"execution":{"iopub.status.busy":"2021-11-08T04:31:59.796550Z","iopub.execute_input":"2021-11-08T04:31:59.796829Z","iopub.status.idle":"2021-11-08T04:34:53.448525Z","shell.execute_reply.started":"2021-11-08T04:31:59.796798Z","shell.execute_reply":"2021-11-08T04:34:53.447592Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Pie plot","metadata":{}},{"cell_type":"code","source":"def matplotlib_visualisation():\n    data = input('Enter the path or file name:')\n    df=pd.read_csv(data)\n    restart = 'y'\n    while restart == 'y':\n        print('1.Line PLot\\n'\n              '2.Bar Plot\\n'\n              '3.Scatter Plot\\n'\n              '4.Histogram PLot\\n'\n              '5.Pie Plot\\n'\n              '6.Area Plot\\n'\n              '7.Donut Plot\\n'\n              '8.Stem Plot\\n'\n              '9.Box Plot\\n'\n              '10.Violin Plot\\n')\n        g = int(input('Select any one plot to plot in matplotlib:'))\n        if g==1:\n            line_plot(df)\n        elif g==2:\n            bar_plot(df)\n        elif g==3:\n            scatter_plot(df)\n        elif g==4:\n            histogram_plot(df)\n        elif g==5:\n            pie_charts(df)\n        elif g==6:\n            area_plot(df)\n        elif g==7:\n            donut_plots(df)\n        elif g==8:\n            stem_plot(df)\n        elif g==9:\n            box_plot(df)\n        elif g==10:\n            violin_plot(df)\n        else:\n            print('Invaild option')\n        q = input('Do you want to continue plotting?(y/n):')\n        if q == 'y':\n            restart = 'y'\n        else:\n            restart = 'n'\nmatplotlib_visualisation()","metadata":{"execution":{"iopub.status.busy":"2021-11-08T04:36:56.592606Z","iopub.execute_input":"2021-11-08T04:36:56.592888Z","iopub.status.idle":"2021-11-08T04:38:32.570963Z","shell.execute_reply.started":"2021-11-08T04:36:56.592856Z","shell.execute_reply":"2021-11-08T04:38:32.570225Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Area plot","metadata":{}},{"cell_type":"code","source":"def matplotlib_visualisation():\n    data = input('Enter the path or file name:')\n    df=pd.read_csv(data)\n    restart = 'y'\n    while restart == 'y':\n        print('1.Line PLot\\n'\n              '2.Bar Plot\\n'\n              '3.Scatter Plot\\n'\n              '4.Histogram PLot\\n'\n              '5.Pie Plot\\n'\n              '6.Area Plot\\n'\n              '7.Donut Plot\\n'\n              '8.Stem Plot\\n'\n              '9.Box Plot\\n'\n              '10.Violin Plot\\n')\n        g = int(input('Select any one plot to plot in matplotlib:'))\n        if g==1:\n            line_plot(df)\n        elif g==2:\n            bar_plot(df)\n        elif g==3:\n            scatter_plot(df)\n        elif g==4:\n            histogram_plot(df)\n        elif g==5:\n            pie_charts(df)\n        elif g==6:\n            area_plot(df)\n        elif g==7:\n            donut_plots(df)\n        elif g==8:\n            stem_plot(df)\n        elif g==9:\n            box_plot(df)\n        elif g==10:\n            violin_plot(df)\n        else:\n            print('Invaild option')\n        q = input('Do you want to continue plotting?(y/n):')\n        if q == 'y':\n            restart = 'y'\n        else:\n            restart = 'n'\nmatplotlib_visualisation()","metadata":{"execution":{"iopub.status.busy":"2021-11-08T04:41:06.942818Z","iopub.execute_input":"2021-11-08T04:41:06.943094Z","iopub.status.idle":"2021-11-08T04:45:04.007943Z","shell.execute_reply.started":"2021-11-08T04:41:06.943062Z","shell.execute_reply":"2021-11-08T04:45:04.007173Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Stem plot","metadata":{}},{"cell_type":"code","source":"def matplotlib_visualisation():\n    data = input('Enter the path or file name:')\n    df=pd.read_csv(data)\n    restart = 'y'\n    while restart == 'y':\n        print('1.Line PLot\\n'\n              '2.Bar Plot\\n'\n              '3.Scatter Plot\\n'\n              '4.Histogram PLot\\n'\n              '5.Pie Plot\\n'\n              '6.Area Plot\\n'\n              '7.Donut Plot\\n'\n              '8.Stem Plot\\n'\n              '9.Box Plot\\n'\n              '10.Violin Plot\\n')\n        g = int(input('Select any one plot to plot in matplotlib:'))\n        if g==1:\n            line_plot(df)\n        elif g==2:\n            bar_plot(df)\n        elif g==3:\n            scatter_plot(df)\n        elif g==4:\n            histogram_plot(df)\n        elif g==5:\n            pie_charts(df)\n        elif g==6:\n            area_plot(df)\n        elif g==7:\n            donut_plots(df)\n        elif g==8:\n            stem_plot(df)\n        elif g==9:\n            box_plot(df)\n        elif g==10:\n            violin_plot(df)\n        else:\n            print('Invaild option')\n        q = input('Do you want to continue plotting?(y/n):')\n        if q == 'y':\n            restart = 'y'\n        else:\n            restart = 'n'\nmatplotlib_visualisation()","metadata":{"execution":{"iopub.status.busy":"2021-11-08T04:45:12.556107Z","iopub.execute_input":"2021-11-08T04:45:12.556368Z","iopub.status.idle":"2021-11-08T04:46:17.992497Z","shell.execute_reply.started":"2021-11-08T04:45:12.556340Z","shell.execute_reply":"2021-11-08T04:46:17.991511Z"},"trusted":true},"execution_count":null,"outputs":[]}]}