Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Python Data visualization 1

Data visualization is the graphical representation of data, making complex relationships easier to understand and communicate. Matplotlib is a Python package for creating 2D graphics, offering various types of plots such as line graphs, pie charts, histograms, and scatter plots. The document provides examples of how to use Matplotlib to create these visualizations with code snippets.

Uploaded by

shaikhmohd9870
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python Data visualization 1

Data visualization is the graphical representation of data, making complex relationships easier to understand and communicate. Matplotlib is a Python package for creating 2D graphics, offering various types of plots such as line graphs, pie charts, histograms, and scatter plots. The document provides examples of how to use Matplotlib to create these visualizations with code snippets.

Uploaded by

shaikhmohd9870
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Data Visualization

-Python
What is data visualization?
Data visualization isthe representation of data through use of common

graphics, such as charts, plots, infographics, and even animations.


These visual displays of information communicate complex data relationships

and data-driven insights in a way that is easy to understand.


It allows us to quickly interpret the data and adjust different variables to

see effects.
Data visualization is a critical step in the data science process, helping teams

and individuals convey data more effectively to colleagues and decision makers.
●Teams that manage reporting systems typically leverage defined template
views to monitor performance.
What is Matplotlib?
Matplotlib is a python package used for 2D graphics.

●Matplotlib is a low level graph plotting library in python that


serves as a visualization utility.
Matplotlib was created by John D. Hunter.

Matplotlib is open source and we can use it freely.


●Matplotlib is mostly written in python, a few segments are written


in C, Objective-C and Javascriptfor Platform compatibility.
Plotting x and y points:
● The plot()function is used to draw points (markers) in a diagram.
● By default, the plot()function draws a line from point to point.
● The function takes parameters for specifying points in the diagram.
● Parameter 1 is an array containing the points on the x-axis.
● Parameter 2 is an array containing the points on the y-axis.
If we need to plot a line from (1, 3) to (8, 10), we have to pass two

arrays [1, 8] and [3, 10] to the plot function.


Types of plots:
PIE CHART

LINE GRAPH

HISTOGRAM or BAR GRAPH


SCATTER PLOT

Pie Charts
Line Chart
Histogram or Bar Graph
Scatter Plot
LINE GRAPH:
from matplotlib import pyplot as plt
plt.plot([5,3,1],[2,7,1])
plt.show()
Line Chart

from matplotlib import pyplot as plt


x=[5,8,10]
y=[12,16,6]
plt.plot(x,y)
plt.title("info")
plt.ylabel("Y AXIS")
plt.xlabel("X AXIS")
plt.show()
Pie Chart
import matplotlib.pyplot as plt

import numpy as np

y = np.array([35, 25, 25, 15])


mylabels = ["Apples", "Bananas", "Cherries", "Dates"]


plt.pie(y, labels = mylabels)


plt.show()

Bar graph:
from matplotlib import pyplot as plt
x1=[5,8,10]
y1=[12,16,6]
x2=[6,9,11]
y2=[6,15,7]
plt.bar(x1,y1,color='g')
plt.bar(x2,y2,color='r')
plt.title("info")
plt.ylabel("Y AXIS")
plt.xlabel("X AXIS")
HISTOGRAM:
from matplotlib import pyplot as plt
age=[5,8,22,21,20,22,43,67,89,45,25]
bin=[0,10,20,30,40,50,60,70,80,90,100]
plt.hist(age,bin,histtype='bar',rwidth=10)
plt.title("histogram")
plt.ylabel("Y AXIS")
plt.xlabel("X AXIS")
plt.legend()
SCATTER PLOT

import matplotlib.pyplot as plt


import numpy as np
x = np.array([5,7,8,7,2,17,2,9,4,11,12,9,6])
y = np.array([99,86,87,88,111,86,103,87,94,78,77,85,86])
plt.scatter(x, y)
plt.show()
import matplotlib.pyplot as plt

import numpy as np

#day one, the age and speed of 13 cars:


x = np.array([5,7,8,7,2,17,2,9,4,11,12,9,6])

y = np.array([99,86,87,88,111,86,103,87,94,78,77,85,86])

plt.scatter(x, y)

#day two, the age and speed of 15 cars:


x = np.array([2,2,8,1,15,8,12,9,7,3,11,4,7,14,12])

y = np.array([100,105,84,105,90,99,90,95,94,100,79,112,91,80,85])

plt.scatter(x, y)

You might also like