Matplotlib is a popular Python library used for data visualization and creating plots from data. It allows creating different types of charts including line charts, bar charts, and pie charts. Line charts connect data points with straight lines and are used to show trends over time. Bar charts represent categorical data with rectangular bars of different heights. Pie charts show proportions between categories by dividing a circle into wedge-shaped slices. Matplotlib provides functions and methods to customize charts with options like colors, labels, titles and more.
PSYPACT- Practicing Over State Lines May 2024.pptx
Data visualization pyplot
1. GVK CHINMAYA VIDYALAYA
SENIOR SECONDARY SCHOOL
Kothuru, Indukurupet, SPS Nellore
Data Visualization pyplot
Class: 12 Subject: Python Teacher: C Vijaya
B.Tech,MBA
2. Matplotlib is one of the most popular Python packages used for data visualization. It is a
cross-platform library for making 2D plots from data in arrays. Matplotlib is written in Python and
makes use of NumPy, the numerical mathematics extension of Python. It can be used in Python
and IPython shells, Jupyter notebook and web application servers also.
Matplotlib has a procedural interface named the Pylab, which is designed to resemble MATLAB,
a proprietary programming language developed by MathWorks. Matplotlib along with NumPy
can be considered as the open source equivalent of MATLAB.
3.
4. Line Chart
The line chart is represented by a series of data points connected with a straight line.Generally,
line charts are used to display trends over time. A line chart or line graph can be created using the
plot() function available in pyplot library.We can not only just plot a line but we can explicitly define
the grid, the x and y-axis scale and labels, title and display options.
7. Bar Chart using Python PyPlot
A bar chart/bar graph, is a very common two-dimensional data visualization
made up of rectangular bars, each for a specific category and it’s length
represents the value of that category.
8. Pie Chart using PyPlot
A pie graph/pie chart is a specialized graph used in statistics. The independent
variable is plotted around a circle.Pie Charts shows proportions and
percentages between categories, by dividing a circle into proportional
segments/parts. Each arc length represents a proportion of each category,
while the full circle represents the total sum of all the data, equal to 100%.
14. A bar plot or bar chart is a graph that represents the category of
data with rectangular bars with lengths and heights that is
proportional to the values which they represent. The bar plots can
be plotted horizontally or vertically. A bar chart describes the
comparisons between the discrete categories. One of the axis of
the plot represents the specific categories being compared, while
the other axis represents the measured values corresponding to
those categories.
Bar chart
19. “%5d”,”%5i” ==> width=5, type=d or i (integer type)
Eg: actual value 123 is printed as __123,because 123 consists only 3 digits
the ouput is padded with 2 blanks.
“%05d”,”%05i” ==> Flag=0 ,width=5, type=d or i (integer type ie..no
decimal point)
Eg:Actual value 123 is printed as 00123,the output is padded with 2
leading zeros to make it have width of 5 digits
Examples of format strings
20. “%03d%%”,”%3i%%” ⇒ width=3 type=d or i (integer type), percentage
sign in the last.
Eg: Actual value 123 is printed as 123%, no leading zero as the width 3 is
fully filled.
“%6.2f”,”%6.2F” ⇒ width=6, precision=2, type=f(float type)
Eg: Actual value 123 is printed as 123.00
“%6.2f%%”,”%6.2F%%” ⇒ width=6, precision=2, type=f(float type)
Eg: Actual value 123 is printed as 123.00%