Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.3 kB
2
Indexable
Never
import matplotlib.pyplot as plt

# Given data
knowledge_score = [88, 75, 79, 78, 92, 94, 68, 76, 80, 93]
calcium_intake = [9.40, 5.33, 9.85, 7.63, 7.83, 8.31, 7.98, 7.74, 8.25, 10.85]
xy = [827.20, 399.75, 778.15, 595.14, 720.36, 781.14, 542.64, 588.24, 660.00, 1009.05]
x_squared = [7744, 5625, 6241, 6084, 8464, 8836, 4624, 5776, 6400, 8649]
y_squared = [88.3600, 28.4089, 97.0225, 58.2169, 61.3089, 69.0561, 63.6804, 59.9076, 68.0625, 117.7225]

# Create scatter plot
plt.figure(figsize=(10, 6))
plt.scatter(knowledge_score, calcium_intake, color='blue', label='Data Points')

# Annotate each point with its respective values of xy, x^2, and y^2
for i, txt in enumerate(xy):
    plt.annotate(f'xy={txt}', (knowledge_score[i], calcium_intake[i]), textcoords="offset points", xytext=(0,10), ha='center')

for i, txt in enumerate(x_squared):
    plt.annotate(f'x^2={txt}', (knowledge_score[i], calcium_intake[i]), textcoords="offset points", xytext=(0,-20), ha='center')

for i, txt in enumerate(y_squared):
    plt.annotate(f'y^2={txt}', (knowledge_score[i], calcium_intake[i]), textcoords="offset points", xytext=(0,-40), ha='center')

# Add labels and title
plt.xlabel('Knowledge Score')
plt.ylabel('Calcium Intake')
plt.title('Scatter Plot of Knowledge Score vs Calcium Intake')
plt.legend()
plt.grid(True)

# Show plot
plt.show()
Leave a Comment