Sitemap

Data Visualization in Python

Python Made Easy - (Article 18) Telugu Explanation

--

Press enter or click to view image in full size

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 matplotlib

Import:

import matplotlib.pyplot as plt
Press enter or click to view image in full size

2. Simple Line Chart Example

import matplotlib.pyplot as plt
x = [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.

Press enter or click to view image in full size

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()
Press enter or click to view image in full size

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()
Press enter or click to view image in full size

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()
Press enter or click to view image in full size

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()
Press enter or click to view image in full size

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()
Press enter or click to view image in full size

PART 2: Seaborn - Stylish Visualization Library

Press enter or click to view image in full size

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 seaborn

Import:

import seaborn as sns
import matplotlib.pyplot as plt

2. 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 chestundi
  • kde=True → data meeda smooth curve line add chestundi
  • color='skyblue' → color ni set chestundi
Press enter or click to view image in full size

3. Bar Plot Example

Bar charts manam compare cheyyadaniki use chestam (example - marks of students).

import pandas as pd
data = {
"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()
Press enter or click to view image in full size

Explanation:

  • barplot() → bar chart draw chestundi
  • hue="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()
Press enter or click to view image in full size

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()
Press enter or click to view image in full size

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 np
data = np.random.rand(4, 4)
sns.heatmap(data, annot=True)
plt.title("Seaborn Heatmap Example")
plt.show()
Press enter or click to view image in full size

Explanation:

  • annot=True → cells lo values display chestundi
  • Dark color → high value
  • Light color → low value

Summary / Key Takeaways

Press enter or click to view image in full size

Common Graph Types:

  • Line Chart → plt.plot() or sns.lineplot()
  • Bar Chart → plt.bar() or sns.barplot()
  • Pie Chart → plt.pie()
  • Histogram → plt.hist() or sns.histplot()
  • Scatter → plt.scatter() or sns.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

--

--