Introduction
Statistical plots help us see the story behind numbers. They show patterns and trends that are hard to find in raw data.
Statistical plots help us see the story behind numbers. They show patterns and trends that are hard to find in raw data.
import matplotlib.pyplot as plt plt.plot(x, y) plt.show()
plt.plot() for line plots, plt.scatter() for scatter plots, and plt.hist() for histograms.plt.show() to display the plot.import matplotlib.pyplot as plt x = [1, 2, 3, 4] y = [10, 20, 25, 30] plt.plot(x, y) plt.show()
import matplotlib.pyplot as plt x = [5, 7, 8, 7, 2] y = [99, 86, 87, 88, 100] plt.scatter(x, y) plt.show()
import matplotlib.pyplot as plt data = [1, 2, 2, 3, 3, 3, 4, 4, 5] plt.hist(data, bins=5) plt.show()
This program shows how ages are spread in a group using a histogram. It helps us see which age ranges have more people.
import matplotlib.pyplot as plt # Sample data: ages of people in a group ages = [22, 25, 29, 24, 30, 35, 40, 42, 41, 38, 36, 28, 27, 26, 23] # Create a histogram to see age distribution plt.hist(ages, bins=5, color='skyblue', edgecolor='black') plt.title('Age Distribution') plt.xlabel('Age') plt.ylabel('Number of People') plt.show()
Plots make it easier to understand data than just looking at numbers.
Choosing the right plot type depends on what you want to learn from the data.
Colors and labels help make plots clearer and more readable.
Statistical plots reveal hidden patterns in data.
They help us understand data distribution, relationships, and outliers.
Using plots makes data analysis faster and more intuitive.
import matplotlib.pyplot as plt plt.hist([1, 2, 2, 3, 3, 3, 4]) plt.show()
import matplotlib.pyplot as plt x = [1, 2, 3] y = [4, 5, 6] plt.scatter(x, y) plt.show()
Pass the test and this pattern moves unknown