0% found this document useful (0 votes)
5 views2 pages

Data Visualization with Matplotlib

The document provides a Python program that visualizes a dataset using Matplotlib. It includes a scatter plot comparing Reading Scores to Placement Scores and a bar chart showing the average Placement Score by Reading Score range. The program reads data from a CSV file and utilizes pandas for data manipulation and visualization.

Uploaded by

rj2004raksha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Data Visualization with Matplotlib

The document provides a Python program that visualizes a dataset using Matplotlib. It includes a scatter plot comparing Reading Scores to Placement Scores and a bar chart showing the average Placement Score by Reading Score range. The program reads data from a CSV file and utilizes pandas for data manipulation and visualization.

Uploaded by

rj2004raksha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Program-5

Write a program to Visualize the dataset to gain insights using Matplotlib


or Seaborn by plotting scatter plots, bar charts.

Source Code:
import pandas as pd
import [Link] as plt

#define the file path:


csv_file_path = 'C:\\Users\\ravik\\venv\\Lab_Programs\\[Link]'

#load the data


data= pd.read_csv(csv_file_path)
data_df=[Link](data)
print("CSV File Data")
print(data)

#Scatter plot of Reading score and placement score


[Link](figsize=(14,7))
[Link](1,2,1) # 1row, 2coloumns, 1st subplot
[Link](data['Reading_Score'], data['Placement_Score'], color='dodgerblue', edgecolor='k',
alpha=0.7)
[Link]('Reading Score Vs Placement Score')
[Link]('Reading Score')
[Link]('Placement Score')
[Link](True)

#Bar chart of Average Placement Score by Reading Score range


bins = [40, 50, 60, 70, 80, 90, 100]
labels = ['40-50', '50-60', '60-70', '70-80', '80-90', '90-100']
data['Reading Score Range']= [Link](data['Reading_Score'], bins=bins, labels=labels, right=False)
group_data = [Link]('Reading Score Range')['Placement_Score'].mean()
[Link](1,2,2) #1Row, 2Columns, 2nd Subplot
group_data.plot(kind='bar', color='salmon')
[Link]('Average Placement Score by Reading Score Ramge')
[Link]('Reading Score Range')
[Link]('Average Placement Score')
[Link](rotation=0) #Keep the category labels horizontal

plt.tight_layout() #Adjust subplots to fit into figure area.


[Link]()

You might also like