Page 342 - Informatics_Practices_Fliipbook_Class12
P. 342

elif choice == 5:

                    mainMenu()



        def visualizeData():
            menu = '''----Analysis DATA MENU----
                    1: Scatter Plot(Nameofsportsperson/ Cashprize)
                    2: Bar Chart (Nameofsportsperson/ Cashprize)

                    3: Scatter Plot(Category/ MedalWon)
                    4: Return to Main Menu
                    '''

             df  =  pd.read_csv('data.csv',names  =  ['NameofEvent',  'Nameofsportsperson',
             'Category','MedalWon','Cashprize'],skiprows=1)

            while(True):
                print(menu)



                choice = int(input("Enter choice:"))
                if choice == 1:
                    print('Scatter plot')

                    yAxis = df['Nameofsportsperson']
                    xAxis = df['Cashprize']
                    plt.title('Name of sports person and cashprize received')
                    plt.ylabel("Name of sports person")

                    plt.xlabel("Cashprize")
                    plt.xticks(rotation=0)

                    plt.ticklabel_format(useOffset=False, axis='x', style='plain')
                    plt.plot(xAxis,yAxis,"y*")
                    plt.tight_layout()
                    plt.show()

                elif choice == 2:
                    print('Bar plot')
                    yAxis = df['Nameofsportsperson']

                    xAxis = df['Cashprize']
                    plt.title('Name of sports person and cashprize received')
                    plt.ylabel("Name of sports person")

                    plt.xlabel("Cashprize")
                    plt.xticks(rotation=0)
                    plt.ticklabel_format(useOffset=False, axis='x', style='plain')

                    plt.barh(yAxis,xAxis,color=['red','green'])


          328  Touchpad Informatics Practices-XII
   337   338   339   340   341   342   343   344   345   346   347