Matplotlib is a widely used Python library for creating static, animated, and interactive visualizations. It provides a flexible framework to generate various plots, including line graphs, bar charts, histograms, and scatter plots. With Matplotlib, users can customize every aspect of a plot, such as labels, colors, legends, and grid lines, making it a powerful tool for data exploration and presentation. It integrates well with libraries like Pandas and NumPy, allowing seamless visualization of datasets.
To create a simple line plot with Matplotlib, first import the library and define your data points:
import matplotlib.pyplot as plt
# Data
ages = [16, 17, 18, 19, 20]
scores = [75, 80, 85, 90, 95]
# Create a figure
plt.figure()
# Plot the data
plt.plot(ages, scores, marker='o', linestyle='-', color='b', label="Score Trend")
# Add labels and title
plt.xlabel("Age")
plt.ylabel("Score")
plt.title("Age vs. Score")
plt.legend()
# Show the plot
plt.show()Output
#img coming soon!