SlideShare une entreprise Scribd logo
1  sur  15
Introduction to
MATPLOTLIB
1
INTRODUCTION TO MATPLOTLIB
● Matplotlib is a popular Python library used for creating visualizations,
charts, and plots.
● It helps in understanding data patterns, trends, and relationships
through graphical representation.
● Importing Matplotlib:
import matplotlib.pyplot as plt
● Matplotlib provides a wide range of plot types, from basic line plots
to complex 3D visualizations. This versatility makes it suitable for
various data analysis and presentation needs, catering to different
domains such as science, engineering, finance, and more.
● Matplotlib seamlessly integrates with other popular Python libraries
such as NumPy and Pandas. This integration allows you to visualize
data structures like arrays and data frames directly without extensive
data manipulation, enhancing productivity and workflow efficiency.
2
CATEGORIZATION OF PLOTS
Matplotlib can be categorized into different types based on the number of
variables included in plots. Here are the categories:
1. Univariate Plots:
● These plots involve analyzing a single variable.
● Examples: Histograms, density plots, box plots, violin plots, bar
plots (for categorical data).
2. Bivariate Plots:
● These plots visualize relationships between two variables.
● Examples: Scatter plots, line plots (connecting two variables), bar
plots (comparing two variables), hexbin plots.
3. Multivariate Plots:
● These plots explore relationships involving more than two
variables.
● Examples: 3D scatter plots, bubble plots, pair plots (showing
relationships among multiple variables), parallel coordinate plots.
3
CATEGORIZATION OF PLOTS
4. Categorical Plots:
● These plots focus on categorical data and its distribution.
● Examples: Bar plots (for categorical data), stacked bar plots,
grouped bar plots, mosaic plots, dendrogram plots.
5. Time Series Plots:
● These plots specifically deal with time-related data.
● Examples: Line plots (over time), area plots, candlestick plots,
seasonal decomposition plots.
6. Statistical Plots:
● These plots emphasize statistical relationships and summaries.
● Examples: Regression plots, distribution plots (showing
distributions and fit), QQ plots (quantile-quantile plots).
4
CATEGORIZATION OF PLOTS
7. Network Plots:
● These plots depict relationships within networks or graphs.
● Examples: Network graphs, directed graphs, node-link diagrams.
8. Interactive Plots:
● These plots allow user interaction for exploring data.
● Examples: Interactive scatter plots, interactive line plots,
interactive heat maps.
9. Composite Plots:
● These plots combine different types of plots to show complex
relationships.
● Examples: Facet grids (grid of subplots), composite heat maps
with annotations.
Matplotlib versatility makes it suitable for creating a wide range of plots,
catering to various data visualization needs.
5
LINE PLOTS IN MATPLOTLIB
● A line plot is a fundamental type of visualization in Matplotlib that
displays data points connected by straight lines.
● It's often used to show the trend or progression of data over a
continuous interval.
● For example:
Suppose you have collected temperature data over a week. You can
create a line plot to visualize how the temperature changes each day.
6
LINE PLOTS IN MATPLOTLIB
● In this example, days represent the x-axis values (days of the week), and
temperatures represent the y-axis values (temperature in degrees Celsius). The
marker, linestyle, and color arguments customize the appearance of the line plot.
● The output of the mentioned program is as follows:
7
BAR PLOTS IN MATPLOTLIB
● A bar plot is a visualization in Matplotlib that uses rectangular bars to
represent categorical data.
● It's commonly used to compare values across different categories or groups.
● For example:
Suppose you want to compare the sales of different products in a store. You
can create a bar plot to visualize the sales for each product
8
BAR PLOTS IN MATPLOTLIB
● In this example, products represent the x-axis categories (product names), and sales
represent the heights of the bars (sales amounts). The color argument specifies the color
of the bars, and xticks(rotation=45) rotates the x-axis labels for better readability.
● The output of the mentioned program is as follows:
9
HISTOGRAMS IN MATPLOTLIB
● A histogram is a graphical representation in Matplotlib that displays
the distribution of continuous data by dividing it into intervals (bins)
and showing the frequency of data points in each bin.
● For example:
Suppose you have a dataset of exam scores and want to visualize
their distribution. You can create a histogram to show how many
students scored within specific score ranges:
10
HISTOGRAMS IN MATPLOTLIB
● In this example, exam_scores is the dataset of scores. The bins parameter specifies
the number of intervals to divide the data into. The histogram displays the
frequency of scores in each bin, helping you understand the distribution of exam
performance.
● The output of the mentioned program is as follows:
11
SCATTER PLOTS IN MATPLOTLIB
● A scatter plot is a visualization in Matplotlib that displays individual
data points as dots on a 2D plane.
● It's used to showcase relationships between two continuous
variables.
● For example:
Imagine you're analyzing the relationship between the study hours
and exam scores of a group of students. A scatter plot can help you
visualize whether there's a correlation between these variables
12
SCATTER PLOTS IN MATPLOTLIB
● In this example, study_hours and exam_scores are the two continuous variables. Each
point on the scatter plot represents a student's study hours and their corresponding exam
score. The marker argument determines the shape of the data points.
● The output of the mentioned program is as follows:
13
SUBPLOTS IN MATPLOTLIB
● Subplots in Matplotlib allow you to create multiple plots within a
single figure, enabling side-by-side comparisons or visualizing related
data.
● For example:
Suppose you want to display two line plots comparing two sets of
data in separate subplots
14
SUBPLOTS IN MATPLOTLIB
● In this example, subplot(1, 2, 1) creates the first subplot, and subplot(1, 2, 2) creates the
second. The tight_layout() call improves spacing between subplots for better presentation.
● The output of the mentioned program is as follows:
15

Contenu connexe

Similaire à Introduction to Matplotlib Library in Python.pptx

Week-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docxWeek-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docx
helzerpatrina
 
Design PatternsChristian Behrenshttpswww.behance.netgall.docx
Design PatternsChristian Behrenshttpswww.behance.netgall.docxDesign PatternsChristian Behrenshttpswww.behance.netgall.docx
Design PatternsChristian Behrenshttpswww.behance.netgall.docx
carolinef5
 

Similaire à Introduction to Matplotlib Library in Python.pptx (20)

Data Visualization in Excel
Data Visualization in ExcelData Visualization in Excel
Data Visualization in Excel
 
Graphical Analysis
Graphical AnalysisGraphical Analysis
Graphical Analysis
 
Week-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docxWeek-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docx
 
Data Visualization using different python libraries.pptx
Data Visualization using different python libraries.pptxData Visualization using different python libraries.pptx
Data Visualization using different python libraries.pptx
 
From data to diagrams: an introduction to basic graphs and charts
From data to diagrams: an introduction to basic graphs and chartsFrom data to diagrams: an introduction to basic graphs and charts
From data to diagrams: an introduction to basic graphs and charts
 
Different types of charts
Different types of chartsDifferent types of charts
Different types of charts
 
Visualization Techniques- Box plot, Line Chart, Scatter plot, Bar chart.
Visualization Techniques- Box plot, Line Chart, Scatter plot, Bar chart.Visualization Techniques- Box plot, Line Chart, Scatter plot, Bar chart.
Visualization Techniques- Box plot, Line Chart, Scatter plot, Bar chart.
 
Design PatternsChristian Behrenshttpswww.behance.netgall.docx
Design PatternsChristian Behrenshttpswww.behance.netgall.docxDesign PatternsChristian Behrenshttpswww.behance.netgall.docx
Design PatternsChristian Behrenshttpswww.behance.netgall.docx
 
19CS3052R-CO1-7-S7 ECE
19CS3052R-CO1-7-S7 ECE19CS3052R-CO1-7-S7 ECE
19CS3052R-CO1-7-S7 ECE
 
Simplifying Matplotlib by examples
Simplifying Matplotlib by examplesSimplifying Matplotlib by examples
Simplifying Matplotlib by examples
 
Graphs in Biostatistics
Graphs in Biostatistics Graphs in Biostatistics
Graphs in Biostatistics
 
Visualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptxVisualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptx
 
Multiple Graphs: Updatable Views
Multiple Graphs: Updatable ViewsMultiple Graphs: Updatable Views
Multiple Graphs: Updatable Views
 
Types of graphs and charts and their uses with examples and pics
Types of graphs and charts and their uses  with examples and picsTypes of graphs and charts and their uses  with examples and pics
Types of graphs and charts and their uses with examples and pics
 
Tips and Tricks for Data Visualization in Python
Tips and Tricks for Data Visualization in PythonTips and Tricks for Data Visualization in Python
Tips and Tricks for Data Visualization in Python
 
Data visualization pyplot
Data visualization pyplotData visualization pyplot
Data visualization pyplot
 
Me 443 4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
Me 443   4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...Me 443   4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
Me 443 4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
 
R programming for data science
R programming for data scienceR programming for data science
R programming for data science
 
Understanding on graph in bpo
Understanding on graph in bpoUnderstanding on graph in bpo
Understanding on graph in bpo
 
A Subgraph Pattern Search over Graph Databases
A Subgraph Pattern Search over Graph DatabasesA Subgraph Pattern Search over Graph Databases
A Subgraph Pattern Search over Graph Databases
 

Dernier

Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
UK Journal
 

Dernier (20)

Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Your enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jYour enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4j
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 

Introduction to Matplotlib Library in Python.pptx

  • 2. INTRODUCTION TO MATPLOTLIB ● Matplotlib is a popular Python library used for creating visualizations, charts, and plots. ● It helps in understanding data patterns, trends, and relationships through graphical representation. ● Importing Matplotlib: import matplotlib.pyplot as plt ● Matplotlib provides a wide range of plot types, from basic line plots to complex 3D visualizations. This versatility makes it suitable for various data analysis and presentation needs, catering to different domains such as science, engineering, finance, and more. ● Matplotlib seamlessly integrates with other popular Python libraries such as NumPy and Pandas. This integration allows you to visualize data structures like arrays and data frames directly without extensive data manipulation, enhancing productivity and workflow efficiency. 2
  • 3. CATEGORIZATION OF PLOTS Matplotlib can be categorized into different types based on the number of variables included in plots. Here are the categories: 1. Univariate Plots: ● These plots involve analyzing a single variable. ● Examples: Histograms, density plots, box plots, violin plots, bar plots (for categorical data). 2. Bivariate Plots: ● These plots visualize relationships between two variables. ● Examples: Scatter plots, line plots (connecting two variables), bar plots (comparing two variables), hexbin plots. 3. Multivariate Plots: ● These plots explore relationships involving more than two variables. ● Examples: 3D scatter plots, bubble plots, pair plots (showing relationships among multiple variables), parallel coordinate plots. 3
  • 4. CATEGORIZATION OF PLOTS 4. Categorical Plots: ● These plots focus on categorical data and its distribution. ● Examples: Bar plots (for categorical data), stacked bar plots, grouped bar plots, mosaic plots, dendrogram plots. 5. Time Series Plots: ● These plots specifically deal with time-related data. ● Examples: Line plots (over time), area plots, candlestick plots, seasonal decomposition plots. 6. Statistical Plots: ● These plots emphasize statistical relationships and summaries. ● Examples: Regression plots, distribution plots (showing distributions and fit), QQ plots (quantile-quantile plots). 4
  • 5. CATEGORIZATION OF PLOTS 7. Network Plots: ● These plots depict relationships within networks or graphs. ● Examples: Network graphs, directed graphs, node-link diagrams. 8. Interactive Plots: ● These plots allow user interaction for exploring data. ● Examples: Interactive scatter plots, interactive line plots, interactive heat maps. 9. Composite Plots: ● These plots combine different types of plots to show complex relationships. ● Examples: Facet grids (grid of subplots), composite heat maps with annotations. Matplotlib versatility makes it suitable for creating a wide range of plots, catering to various data visualization needs. 5
  • 6. LINE PLOTS IN MATPLOTLIB ● A line plot is a fundamental type of visualization in Matplotlib that displays data points connected by straight lines. ● It's often used to show the trend or progression of data over a continuous interval. ● For example: Suppose you have collected temperature data over a week. You can create a line plot to visualize how the temperature changes each day. 6
  • 7. LINE PLOTS IN MATPLOTLIB ● In this example, days represent the x-axis values (days of the week), and temperatures represent the y-axis values (temperature in degrees Celsius). The marker, linestyle, and color arguments customize the appearance of the line plot. ● The output of the mentioned program is as follows: 7
  • 8. BAR PLOTS IN MATPLOTLIB ● A bar plot is a visualization in Matplotlib that uses rectangular bars to represent categorical data. ● It's commonly used to compare values across different categories or groups. ● For example: Suppose you want to compare the sales of different products in a store. You can create a bar plot to visualize the sales for each product 8
  • 9. BAR PLOTS IN MATPLOTLIB ● In this example, products represent the x-axis categories (product names), and sales represent the heights of the bars (sales amounts). The color argument specifies the color of the bars, and xticks(rotation=45) rotates the x-axis labels for better readability. ● The output of the mentioned program is as follows: 9
  • 10. HISTOGRAMS IN MATPLOTLIB ● A histogram is a graphical representation in Matplotlib that displays the distribution of continuous data by dividing it into intervals (bins) and showing the frequency of data points in each bin. ● For example: Suppose you have a dataset of exam scores and want to visualize their distribution. You can create a histogram to show how many students scored within specific score ranges: 10
  • 11. HISTOGRAMS IN MATPLOTLIB ● In this example, exam_scores is the dataset of scores. The bins parameter specifies the number of intervals to divide the data into. The histogram displays the frequency of scores in each bin, helping you understand the distribution of exam performance. ● The output of the mentioned program is as follows: 11
  • 12. SCATTER PLOTS IN MATPLOTLIB ● A scatter plot is a visualization in Matplotlib that displays individual data points as dots on a 2D plane. ● It's used to showcase relationships between two continuous variables. ● For example: Imagine you're analyzing the relationship between the study hours and exam scores of a group of students. A scatter plot can help you visualize whether there's a correlation between these variables 12
  • 13. SCATTER PLOTS IN MATPLOTLIB ● In this example, study_hours and exam_scores are the two continuous variables. Each point on the scatter plot represents a student's study hours and their corresponding exam score. The marker argument determines the shape of the data points. ● The output of the mentioned program is as follows: 13
  • 14. SUBPLOTS IN MATPLOTLIB ● Subplots in Matplotlib allow you to create multiple plots within a single figure, enabling side-by-side comparisons or visualizing related data. ● For example: Suppose you want to display two line plots comparing two sets of data in separate subplots 14
  • 15. SUBPLOTS IN MATPLOTLIB ● In this example, subplot(1, 2, 1) creates the first subplot, and subplot(1, 2, 2) creates the second. The tight_layout() call improves spacing between subplots for better presentation. ● The output of the mentioned program is as follows: 15