How to visualize data using line graph in python?

Description

To visualize the data using line graph in python.

   First import needed library functions.

   Load the data sample in to data Frame.

   Using plot() from matplot library, we can draw line graph for corresponding variables.

#import library

import matplotlib.pyplot as plt

import pandas as pd

#10 sample data

data={‘name':[‘sathish’,’raj’,’raja’,’krishna’,

‘yusuf’,’praveen’,’sangee’,’ezhil’,’dinesh’

,’ganesh’], ‘salary':[100,200,300,400,

500,400,300,200,100,50],’age':[22,26,

25,23,30,29,23,23,25,25], ‘rating’

:[4,3.24,2.5,2.25,2,2.25,2.5,2.75,3.2,4.2],

‘bonus':[2500,1200,900,3000,1800,

1400,850,250,750,1000]}

#creating data frame

df=pd.DataFrame(data)

plt.plot(df[‘salary’],df[‘age’],color=’g’)

plt.show()

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit