Data Visualization in Python
Python Made Easy - (Article 18) Telugu Explanation
PART 1: Matplotlib — Base Visualization Library
1. What is Matplotlib?
Matplotlib ane library Python lo base visualization library.
Ante, idi graphs and charts create cheyadaniki base tool laga panichestundi.
Dini tho manam line charts, bar charts, scatter plots, pie charts mariyu inka chala rakala graphs create cheyyachu.
Installation:
pip install matplotlibImport:
import matplotlib.pyplot as plt2. Simple Line Chart Example
import matplotlib.pyplot as pltx = [1, 2, 3, 4, 5]
y = [10, 20, 15, 30, 25]plt.plot(x, y)
plt.title("Simple Line Chart")
plt.xlabel("X Values")
plt.ylabel("Y Values")
plt.show()
Output: Line connecting all points
plt.show() → displays the chart on the screen.
3. Customizing Line Chart
Manam color, line style change cheyyachu and markers add cheyyachu.
plt.plot(x, y, color='red', linestyle='--', marker='o')
plt.title("Customized Line Chart")
plt.show()4. Bar Chart Example
Categories compare cheyyadaniki use avtundhi.
names = ["Naresh", "Ravi", "Sai"]
marks = [85, 90, 75]plt.bar(names, marks, color='orange')
plt.title("Students Marks")
plt.xlabel("Names")
plt.ylabel("Marks")
plt.show()Manam things like (like sales, marks, etc.) compare chesetapudu use avthundhi
5. Pie Chart Example
Used to show parts of a whole.
sizes = [40, 35, 25]
labels = ["Python", "Java", "C++"]plt.pie(sizes, labels=labels, autopct='%1.1f%%')
plt.title("Programming Language Usage")
plt.show()6. Scatter Plot Example
Rendu variables madhya Relationship choopinchadaniki use avthundhi
x = [1, 2, 3, 4, 5]
y = [5, 15, 10, 25, 20]plt.scatter(x, y, color='green')
plt.title("Scatter Plot Example")
plt.xlabel("X Axis")
plt.ylabel("Y Axis")
plt.show()7. Histogram Example
Data distribution ni choopinchadaniki use avthundhi
data = [12, 15, 13, 20, 18, 21, 19, 23, 25, 22, 17, 14]
plt.hist(data, bins=5, color='purple')
plt.title("Histogram Example")
plt.show()PART 2: Seaborn - Stylish Visualization Library
1. What is Seaborn?
Seaborn ane library Matplotlib meeda build ayyindi (means, it is built on top of Matplotlib).
Matplotlib base library ayithe, Seaborn dantopai design add chesi, graphs ni beautiful and simple ga chesestundi.
Seaborn automatic ga nice colors, smooth styles, and themes add chestundi - so manam graph ni manually design cheyyalsina avasaram ledhu.
Get D Naresh’s stories in your inbox
Join Medium for free to get updates from this writer.
Installation:
pip install seabornImport:
import seaborn as sns
import matplotlib.pyplot as plt2. Simple Histogram
Histogram ane di data distribution ni chupinchedaniki use chestam.
data = [12, 15, 13, 20, 18, 21, 19, 23, 25]
sns.histplot(data, kde=True, color='skyblue')
plt.title("Seaborn Histogram Example")
plt.show()histplot()→ histogram ni create chestundikde=True→ data meeda smooth curve line add chestundicolor='skyblue'→ color ni set chestundi
3. Bar Plot Example
Bar charts manam compare cheyyadaniki use chestam (example - marks of students).
import pandas as pddata = {
"Name": ["Naresh", "Ravi", "Sai", "Teja"],
"Marks": [85, 90, 75, 95],
"Subject": ["Python", "Java", "C++", "Python"]
}df = pd.DataFrame(data)
sns.barplot(x="Name", y="Marks", hue="Subject", data=df)
plt.title("Marks Comparison by Subject")plt.show()
Explanation:
barplot()→ bar chart draw chestundihue="Subject"→ subject batti different colors chupistundi- Easy ga categories compare cheyyachu (Python vs Java etc.)
4. Line Plot Example
Line chart time - based trends chupinchedaniki perfect (example: monthly sales).
data = {
"Month": ["Jan", "Feb", "Mar", "Apr", "May"],
"Sales": [10000, 12000, 8000, 15000, 17000]
}
df = pd.DataFrame(data)
sns.lineplot(x="Month", y="Sales", data=df, marker="o", color="red")
plt.title("Monthly Sales Trend")
plt.show()Explanation:
- Line smooth ga draw chestundi points connect chestu.
marker="o"→ dots add chestundi- Perfect for showing growth or decrease in numbers over time.
5. Box Plot Example
Box plot ane di data spread, median and outliers ni chupistundi (ante extreme values).Used to see data distribution, median, and outliers.
marks = [85, 90, 75, 60, 95, 88, 70]
sns.boxplot(marks, color="orange")
plt.title("Marks Distribution")
plt.show()6. Heatmap Example
Heatmap data lo relationship (correlation) chupinchedaniki use chestam.
Manaki 2D matrix laga data untundi, andulo colors tho values ni represent chestundi.
import numpy as npdata = np.random.rand(4, 4)
sns.heatmap(data, annot=True)
plt.title("Seaborn Heatmap Example")
plt.show()Explanation:
annot=True→ cells lo values display chestundi- Dark color → high value
- Light color → low value
Summary / Key Takeaways
Common Graph Types:
- Line Chart →
plt.plot()orsns.lineplot() - Bar Chart →
plt.bar()orsns.barplot() - Pie Chart →
plt.pie() - Histogram →
plt.hist()orsns.histplot() - Scatter →
plt.scatter()orsns.scatterplot() - Box / Heatmap →
sns.boxplot(),sns.heatmap()
Practice Questions
1️.Create a bar chart comparing 5 students’ marks.
2️.Plot a pie chart showing favorite fruits percentage.
3️.Create a line graph for temperature change for 7 days.
4️.Use Seaborn to display a histogram with kde=True.
5️.Draw a heatmap showing 5×5 random matrix data.
Next & Previous
Next article: 👉 19. Building Simple CLI Projects
Previous article: 👉 17. Pandas — Data Analysis









