Page 301 - AI_Ver_3.0_class_11
P. 301
• The scatterplot is a valuable tool for calculating correlation. Variable relationships can be categorised in a variety of
ways, including positive or negative, strong or weak, linear or nonlinear.
• This graph’s strength lies in its ability to clearly depict trends, clusters, and relationships within datasets.
The function scatter() is used to visualise a scatterplot in Python.
Program 8: Create a Scatter Plot Graph for number of hours students spend studying per week with respect
to percentage scored using Python
Study Time 4 3.5 5 2 3 6.5 0.5 3.5 4.5 5 1 1.5 3 5.5
percentage 82 82 90 74 40 97 51 75 86 85 62 75 70 91
import matplotlib.pyplot as plt
# Data
study_time = [4, 3.5, 5, 2, 3, 6.5, 0.5, 3.5, 4.5, 5, 1, 1.5, 3, 5.5]
percentage = [82, 82, 90, 74, 40, 97, 51, 75, 86, 85, 62, 75, 70, 91]
# Create scatter plot using scatter() function
plt.scatter(study_time, percentage)
# Add title and labels
plt.title('Study Time vs. Percentage Scored')
plt.xlabel('Study Time (hours)')
plt.ylabel('Percentage Scored')
# Show plot
plt.show()
Output:
Data Literacy—Data Collection to Data Analysis 299

