0% found this document useful (0 votes)
23 views13 pages

Data Vissualization 12

Data Vissualization 12 cbsc bord exam

Uploaded by

Ushim Arora
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)
23 views13 pages

Data Vissualization 12

Data Vissualization 12 cbsc bord exam

Uploaded by

Ushim Arora
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/ 13

Data Visualization

Introduction
Data visualization refers to the graphical representation of
information and data using visual elements like charts,
graphs and maps etc. It is useful in decision making.
Matplotlib :- It is Python library that provides many
interfaces and functionality for 2 D graphics.
Pyplot :- It is a collection of methods within matplotlib
which allows user to construct 2 D plots.
Importing PyPlot : -
import matplotlib.pyplot
or
import matplotlib.pyplot as pl #pl is alias name
Using NumPy Arrays
• Array :- It is a collection of homogenous elements.
• import numpy as np
Example :
import numpy as np
List = [1,2,3,4]
a1= np.array(List)
print (a1)
Note : Individual elements of array accessed by using
<array-name>[index]
Attribute associate with array
• shape : attributes gives the dimensions of a NumPy
array.

• Itemsize :- attributes returns the length of each


element of array in bytes.
[1. 4. 7.]

Useful ways of creating NumPy Arrays


1. Creating arrays with a numerical range using arange() :
Syntax :
<arrayname>=numpy.arange([start],stop[,step][,dtype])
e.g ar=np.arange( 1,7,2,np.int8)
output : 1,3,5
2. Creating arrays with a numerical range using linespace():
syntax :
<arrayname>=numpy.linspace([start],[stop],[no.of values to be generated)
*linspace gives evenly space between two given limits.
e.g ar=np.linspace( 1,7,3)
output :
[1. 4. 7.]
Creating charts with matplotlib library pyplot interfaces
• Line Chart : It is a type of chart which displays
information as a series of data points called markers
connected by straight line segments. The Pyplot interface
offers plot() function for creating a line graph.
Example :
a=[1,2,3,4,5]
b=[2,4,6,8,10]
import matplotlib.pyplot as pl
pl.plot(a,b)
• To show the axes lables:
<matplotlib.pyplot>.xlable(<str>) &
<matplotlib.pyplot>.ylable(<str>)
• Changing line color
<matplotlib.pyplot>.plot(<data1>[,data2],<color code>)
Different color code:
Character Color Character Color Character Color
‘b’ Blue ‘g’ Green ‘r’ Red
‘m’ Magenta ‘y’ Yellow ‘k’ Black
‘c’ Cyan ‘w’ white
• To change the line width
<matplotlib.pyplot>.plot(<data1>[,data2],<linewidth=width>
• To change the linestyle
<matplotlib.pyplot>.plot(<data1>[,data2],<linestyle=‘ls_name> different linestyle
are as follows:
solid, dashed, dashdot and dotted
• To change Marker type, size and color
marker is the data points being plotted are called markers.
marker=<valid marker type>, markersize=<in points>, markeredgecolor=<valid
color>
• Note:-
(i) If we not specify markeredgecolor separately in plot() the markeredge takes the
same color as the line.
(ii) If no linestyle argument pass with line color and markerstyle string python will
only plot the marker and not the line.
Different marker type
Marker Description Marker Description Marker Description
‘.’ Point marker ‘h ’ Hexagon1 marker ‘|’ Vline marker
‘,’ Pixel marker ‘ H’ Hexagon2 marker ‘ _’ Hline marker
‘ o’ Circle marker ‘ 1’ Tri_down marker ‘ v’ Triangle_dow
n marker
‘ +’ Plus marker ‘ 2’ Tri_up marker ‘ ^’ Triangle_up
marker
‘ x’ X marker ‘ 3’ Tri_left marker ‘ p’ Pentagon
marker
‘ D’ Diamond marker ‘ 4’ Tri_right marker ‘ *’ Star marker
‘ d’ Thin_diamond marker ‘ < ’ Triangle_left marker
‘ s’ Square marker ‘ >’ Triangle_right marker

You might also like