0% found this document useful (0 votes)
6 views26 pages

12-data visualization-1

The document provides an overview of data visualization, emphasizing its importance in business for simplifying complex data, identifying trends, supporting decision-making, and improving communication. It introduces Matplotlib, a Python library for creating various types of plots such as line plots, bar charts, pie charts, histograms, and scatterplots, each serving specific visualization purposes. Additionally, it includes practical examples and code snippets for implementing these visualizations.

Uploaded by

snehashoukat6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views26 pages

12-data visualization-1

The document provides an overview of data visualization, emphasizing its importance in business for simplifying complex data, identifying trends, supporting decision-making, and improving communication. It introduces Matplotlib, a Python library for creating various types of plots such as line plots, bar charts, pie charts, histograms, and scatterplots, each serving specific visualization purposes. Additionally, it includes practical examples and code snippets for implementing these visualizations.

Uploaded by

snehashoukat6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Programming Language for Business

Analytics-MGT173
Rabail Asghar
Lecturer (Computer Science)
COMSATS University Islamabad, Lahore Campus

1
Topics to cover

Data Visualization with matplotlib

2
Data Visualization
• What is Data Visualization?
• Data visualization is the graphical representation of
information and data. It uses visual elements like
charts, graphs, and plots to make complex data
easy to understand and analyze.

3
Data Visualization
• Why is Data Visualization Important in Business?
1.Simplifies Complex Data: Makes large datasets
easy to interpret.
2.Identifies Trends: Helps spot patterns and trends
over time.
3.Supports Decision-Making: Provides actionable
insights for better business decisions.
4.Improves Communication: Visuals are easier to
share and explain than raw data.

4
matplotlib
• Matplotlib is a Python library used to create graphs
and charts for data visualization. It helps us to
better understand and present data.

5
6
7
Explanation
• matplotlib.pyplot as plt:
• This creates a shorter alias (plt) for the module, so we
can use it more easily in the code. Instead of typing
matplotlib.pyplot every time, we can just write plt.
• The plt.plot() function creates a line graph connecting
the points defined by months and sales. It automatically
chooses colors, line styles, and markers unless you
specify them.
• E.g
plt.plot(months, sales, color='red', linestyle='--',
marker='o')
8
9
Types of Plots in
Matplotlib
• 1. Line Plot
• Used to display trends over intervals.
• Tracks a variable over intervals (like days, months,
years).

10
11
Line plot
• Manually setting the y-axis distribution

12
13
2. Bar Chart
• Used for comparing different categories.
• Shows the difference in quantities across
categories.

14
15
2. Bar Chart
• # Set the y-axis ticks manually
• plt.yticks([0, 300, 600, 900, 1000, 1300])

16
Pie-chart
Purpose: Used to show proportions of a whole.
• Code:

17
18
Explanation
• autopct='%1.1f%%’:
• This parameter formats the percentage values. The
%1.1f%% format string means:
• %1.1f: Display a floating-point number with one decimal
place.
• %%: To display the percentage sign (%).

19
Histogram
• Displays the distribution of data.

• Histogram: It divides data into intervals (bins) and


shows the frequency of values in each bin.
• work well when dataset can be grouped (e.g., 0-10,
11-20, etc.) and see how many data items eng,
months fall into each bin.

20
Histogram

21
22
Scatterplot
• A scatterplot is useful for visualizing the
relationship between two continuous variables.
• It shows how much one variable is affected by
another, which can help identify correlations
(positive, negative, or no correlation). Typically, the
x-axis and y-axis represent different continuous
variables.

23
24
25
Practice-1
• Read monthly_sales data from CSV file and plot
graphs between months and sales.

26

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy