Data Visualization in Python with 5 Basic Charts
- Jincy Maria Preethi
- Jun 3
- 3 min read

Data visualization is an important skill for every data analyst. Instead of looking at large tables of numbers, charts and graphs make data easier to understand. They help people quickly spot trends, patterns, and important information. Python offers useful tools like Pandas, Matplotlib, and Seaborn that make it simple to create charts and turn raw data into clear and meaningful visuals.
In this article, we'll explore five easy Python charts that every beginner data analyst should know.
1. Bar Chart
2. Line Chart
3. Pie Chart
4. Histogram
5. Scatter Plot
First Let us see, When to use each of this chart:
CHART TYPE | BEST FOR |
Bar Chart | Comparing Categories |
Line Chart | Showing Trends Over Time |
Pie Chart | Displaying Proportions |
Histogram | Understanding Data Distribution |
Scatter Plot | Finding Relationship Between Variables |
1. Bar Chart:
When you need to compare data from different categories, a bar chart is often the best choice. It presents information using rectangular bars, helping viewers quickly understand differences and trends in the data.
Practical Examples:
Comparing product sales
Survey results
Revenue by department
Python Code for Creating Bar Chart:
import matplotlib.pyplot as plt
products = ['A', 'B', 'C', 'D']
sales = [120, 150, 90, 200]
plt.bar(products, sales)
plt.title('Product Sales')
plt.xlabel('Products')
plt.ylabel('Sales')
plt.show()
Advantage:
Bar charts make it easy to compare values and quickly identify the highest and lowest performers.
2. Line Chart:
When you want to see how something changes from one time period to another, line chart is a great choice. It connects data points with lines to clearly show trends.
Practical Examples:
Monthly sales trends
Website traffic analysis
Stock price movements
Python Code for Creating Line Chart:
import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5]
y = [50,52,51,55,53]
plt.plot(x, y, marker='o', linestyle='-', color='b', label='Sales')
plt.title('Stock Price Movement')
plt.xlabel('Days')
plt.ylabel('Stock Price')
plt.show()
Advantage:
Line charts allow analysts to see how data moves over time, making it easier to identify patterns, measure progress, and detect repeating trends.
3. Pie Chart:
Pie charts are used to display how a whole is divided among different categories. Each slice represents a category's contribution to the total.
Practical Examples:
Market share analysis
Budget allocation
Customer segmentation
Python Code For Creating Pie Chart:
import matplotlib.pyplot as plt
color = ['Red', 'Blue', 'Green', 'yellow']
respondents = [40,30,20,10]
custom_colors = ['#FF0000','#0000FF','#008000','#FFFF00']
plt.pie(respondents, labels=color,colors=custom_colors)
plt.title('Survey Respondents by Favorite Color')
plt.show()
Advantage:
Pie charts are useful for showing proportions and percentages in an easy-to-understand format.
4. Histogram:
A histogram displays the pattern of numerical data, making it easier to see where most values are concentrated and how the data is distributed.
Practical Examples:
Employee salaries
Exam scores
Customer age distribution
Python Code For Creating Histogram:
import matplotlib.pyplot as plt
scores = [55, 60, 65, 70, 72, 75, 80, 82, 85, 90, 95]
plt.hist(scores, bins=5)
plt.title('Exam Score Distribution')
plt.xlabel('Scores')
plt.ylabel('Frequency')
plt.show()
Advantage:
Histograms make it easier to see how data is distributed, where most values are grouped, and whether there are any unusual values.
5. Scatter plot:
Scatter plots are used to examine how one variable changes in relation to another. They help reveal whether a relationship exists between the two variables.
Practical Examples:
Advertising spend vs. sales
Study hours vs. exam scores
Temperature vs. electricity usage
Python Code For Creating Scatter Plot:
import matplotlib.pyplot as plt
study_hours = [1, 2, 3, 4, 5, 6, 7]
scores = [50, 55, 60, 70, 75, 85, 90]
plt.scatter(study_hours, scores)
plt.title('Study Hours vs Exam Scores')
plt.xlabel('Study Hours')
plt.ylabel('Exam Scores')
plt.show()
Advantage:
Scatter plots reveal how two sets of data interact, making it easier to spot trends, connections, and relationships.
To Conclude, Learning these five basic charts is an excellent starting point for any aspiring data analyst. Bar charts, line charts, pie charts, histograms, and scatter plots can help you answer a wide range of business and analytical questions. By mastering these visualizations in Python, you'll be able to turn raw data into meaningful insights and communicate your findings more effectively.

