Types of Charts in Data Science #
Charts help visualize data for better understanding, pattern detection, and decision making.
Line Chart #
- Purpose: Show trends over time
- Example: Stock prices over months
- Tools: Python (
matplotlib), Excel - Code Example:
import matplotlib.pyplot as plt
x = [1,2,3,4]
y = [10,20,15,25]
plt.plot(x, y)
plt.title("Line Chart Example")
plt.show()Bar Chart #
- Purpose: Compare categories
- Example: Sales of different products
- Tools: Python (
matplotlib), Excel - Code Example:
x = ['A','B','C']
y = [10,20,15]
plt.bar(x, y)
plt.title("Bar Chart Example")
plt.show()Pie Chart #
- Purpose: Show proportions of a whole
- Example: Market share of companies
- Tools: Python (
matplotlib), Excel - Code Example:
labels = ['X','Y','Z']
sizes = [30,50,20]
plt.pie(sizes, labels=labels, autopct='%1.1f%%')
plt.title("Pie Chart Example")
plt.show()Histogram #
- Purpose: Show distribution of data
- Example: Age distribution of customers
- Tools: Python (
matplotlib), Excel - Code Example:
data = [22,25,22,30,28,30,25]
plt.hist(data, bins=5)
plt.title("Histogram Example")
plt.show()Scatter Plot #
- Purpose: Show relationship between two variables
- Example: Height vs Weight
- Tools: Python (
matplotlib,seaborn), Excel - Code Example:
x = [1,2,3,4]
y = [10,20,15,25]
plt.scatter(x, y)
plt.title("Scatter Plot Example")
plt.show()| Chart Type | Purpose | Example | Tools/Techniques | Code Example (Python) |
|---|---|---|---|---|
| Line Chart | Show trends over time | Stock prices over months | Python (matplotlib), Excel | plt.plot(x, y); plt.show() |
| Bar Chart | Compare categories | Sales of products | Python (matplotlib), Excel | plt.bar(x, y); plt.show() |
| Pie Chart | Show proportions of a whole | Market share | Python (matplotlib), Excel | plt.pie(sizes, labels=labels, autopct='%1.1f%%'); plt.show() |
| Histogram | Show data distribution | Age distribution of customers | Python (matplotlib), Excel | plt.hist(data, bins=5); plt.show() |
| Scatter Plot | Show relationship between two variables | Height vs Weight | Python (matplotlib, seaborn), Excel | plt.scatter(x, y); plt.show() |
