L3_plotting With Pyplot
L3_plotting With Pyplot
Lets understand :
• What is data visualization?
• Why data visualization?
• What is Matplotlip?
• Types of Matplotlip
Why do we need data visualization?
-Data visualization is the act of taking information (data)
and placing it into a visual context, such as a map or
graph.
-Data visualizations make big and small data easier for the
human brain to understand, and visualization also makes it
easier to detect patterns, trends, and outliers in groups of
data.
• import matplotlib.pyplot as pl
Here, pl is an alias/ short name given to pyplot module.
• To access the methods from pyplot:
EG: pl.plot(X,Y) here with the help of alias we can access the method
Working with plot methods
import numpy as np
import matplotlib.pyplot as pl
x=np.linspace(1,5,6)
y=np.log(x)
pl.plot(x,y)
pl.show()
Basic of simple plotting
• Open Page 174
• Read all charts and see how they look like on PG 165
Line chart using plot() function
import numpy as np
import matplotlib.pyplot as pl
a=[1,2,3,4]
b=[2,4,6,8] #b has double values of list a
c=[1,4,9,16] #c has squares of list a
pl.plot(a,b)
pl.xlabel("Numbers")
pl.ylabel("Double Numbers")
pl.show()
scatter chart
import numpy as np
import matplotlib.pyplot as pl
a=[1,2,3,4]
b=[2,4,6,8] #b has double values of list a
c=[1,4,9,16] #c has squares of list a
pl.scatter(a,b) #scatter
pl.xlabel("Numbers")
pl.ylabel("Double Numbers")
pl.show()
Combination of both line and scatter
import numpy as np
import matplotlib.pyplot as pl
a=[1,2,3,4]
b=[2,4,6,8] #b has double values of list a
c=[1,4,9,16] #c has squares of list a
pl.plot(a,b) #line chart
pl.scatter(a,b) #scatter
pl.xlabel("Numbers")
pl.ylabel("Double Numbers")
pl.show()
Difference between line and scatter chart.
Line chart/line graph
1. A line chart or line graph is a type of Scatter chart/ graph
chart which displays information as a 1. Scatter plot is a graph of two sets of data
series of data points called ‘markers’ along the two axes. It is used to visualize
connected by straight line segments. the relationship between the two
variables.
2. Line graphs are usually used to find
relationship between two data sets on 2. The points are randomly distributed with
different axis; for instance X, Y. no pattern.
3. With pyplot, a line chart is created using 3. With pyplot, a scatter chart is created
plot() function. using scatter() function.
4. EG: 4. EG:
import matpotlib.pyplot.plt import matpotlib.pyplot.plt
x = [2, 4, 6] x = [2, 4, 6]
y = [1, 3, 5] y = [1, 3, 5]
plt.plot(x, y) plt. scatter(x, y)
plt.show() plt.show()
#EG2 PG179 Marks is a list that stores marks of a student in 10 units
tests. WAP to plot the student's performance in these 10 unit test.
import matplotlib.pyplot as plt NOTE:
matplotlib.pyplot.figure(figsize=(<width>,<length>))
week = [1,2,3,4,5,6,7,8,9,10] or
marks = [12,10,10,15,17,25,12,22,35,40] plt.figure(figsize =(<width>,<length>))
plt.figure(figsize=(15,7))
Will show the plot with specified size. EG
plt.grid(True)
plt.plot(week,marks) plt.figure(figsize=(15,7))
plt.xlabel('WEEK') Here, 15 units wide i.e. x-coordinate and
plt.ylabel('UNIT TEST MARKS') 7 units long i.e. y-coordinate.
plt.title('student performance')
plt.grid(True) will show grid on plot
plt.show()
Changing Line Color, Width and Style
matplotlib.pyplot.plot(X,Y,<color code>)
In addition to the above you can also include the names like : red,
light green, sky blue, dark grey, brown etc. , hex string (‘#008800’ )
Gray shades can be given as a string encoding a float in the 0-1 range,
Changing line Width/Thickness
matplotlib.pyplot.plot(X,Y, linewidth=<width>)
An additional parameter to plot( ) to specify the width value in points.
Line width/thickness is measured in points EG. 0.56, 3.14 etc
Changing line style
matplotlib.pyplot.plot(X,Y, linestyle=‘solid’|‘dashed’|‘dashdot’|‘dotted’)
OR
matplotlib.pyplot.plot(X,Y, ls=‘solid’|‘dashed’|‘dashdot’|‘dotted’)
OR
matplotlib.pyplot.plot(X,Y, linestyle=‘-’|‘--’|‘-.’|‘:’)
OR
matplotlib.pyplot.plot(X,Y, ls=‘-’|‘--’|‘-.’|‘:’)
x=np.arange(0.,10,0.1)
a=np.cos(x)
b=np.sin(x)
plt.figure(figsize=(25,10)) #25 is width and 10 ht
plt.plot(x,a, 'b',ls=':') #'b' is blue color
plt.plot(x,b, 'r’) # ‘r’ is red color
plt.show()
ar2=[1,7,21,35,35,21,7,1]
#calculating sin() cos() tan() values
s2=np.sin(ar2)
c2=np.cos(ar2)
t2=np.tan(ar2)
ar2=[1,7,21,35,35,21,7,1]
#calculating sin() cos() tan() values
s2=np.sin(ar2)
c2=np.cos(ar2)
t2=np.tan(ar2)
plt.plot(ar2,s2, color=‘c') #sine line, 'c' is cyan color
plt.plot(ar2,c2,'r') #cosine line, 'r' is red color
plt.plot(ar2,t2,'k',marker='d',markersize=6, markeredgecolor='b') marker =‘d’ ie diamond
plt.xlabel('Array Values') & markersize is 6 &
color is blue
plt.ylabel('Sine,Cosine & Tangent Values')
plt.show()
#Linestyle is solid and r+ is markertype with color code are same
ar2=[1,7,21,35,35,21,7,1]
#calculating sin() values
s2=np.sin(ar2)
plt.plot(ar2,s2,'r+',linestyle='solid', markersize=10)
plt.xlabel('Array Values')
plt.ylabel('Sine,Cosine & Tangent Values')
plt.show()
#Linestyle is solid and r+ is markertype with color code green
import matplotlib.pyplot as plt
import numpy as np
ar2=[1,7,21,35,35,21,7,1]
#calculating sin() values
s2=np.sin(ar2)
plt.plot(ar2,s2,'r+',linestyle='solid',markeredgecolor='g')
plt.xlabel('Array Values')
plt.ylabel('Sine,Cosine & Tangent Values')
plt.show()
import matplotlib.pyplot as plt
import numpy as np
ar2=[1,7,21,35,35,21,7,1]
#calculating sin() values
s2=np.sin(ar2)
plt.plot(ar2,s2,'go’)
# ‘go’ g is for green color and ‘o’ is big circle i.e. scatter
plt.xlabel('Array Values')
plt.ylabel('Sine,Cosine & Tangent Values')
plt.show()
[NOTE: if linestyle argument is not specified than will NOT show the line
but will only display the markers]
Programs practical work
• 1st 10 terms of Fibonacci series EG4 PG184
• EG5 PG 185
Creating scatter charts
• The scatter chart is a graph of plotted points on two axes that show
the relationship between two sets of data.
• The scatter charts can be created through two functions of pyplot
library:
1) plot( ) function
2) scatter( ) function
Creating scatter charts using plot( ) function
plotting scatter chart using plot( )
import matplotlib.pyplot as plt
import numpy as np
ar2=[1,7,21,35,35,21,7,1]
#calculating sin() values
s2=np.sin(ar2)
plt.plot(ar2,s2,'o')
# ‘‘o’ is big circle i.e. scatter default color is blue
plt.xlabel('Array Values')
plt.ylabel('Sine Values')
plt.show()
plotting scatter chart using plot( )
import matplotlib.pyplot as plt
import numpy as np
ar2=[1,7,21,35,35,21,7,1]
#calculating sin() values
s2=np.sin(ar2)
plt.plot(ar2,s2,'<', markersize=20)
#'<' is for triangle and observe the markersize
plt.xlabel('Array Values')
plt.ylabel('Sine Values')
plt.show()
Programs practical work
• EG 6 PG176,177
• EG 7 PG 177
Creating scatter charts using scatter( ) function
• scatter( ) function is another function to create scatter chart of pyplot
library.
• Syntax :
matplotlib.pyplot.scatter(<array1>,<array2>)
OR
plt.scatter(<array1>,<array2>)
OR
plt.scatter(X,Y, s=markersize, c=markercolor, marker=‘markerstyle’)
Argument X,Y are arrays.
Creating scatter charts using scatter( ) function
#plotting scatter chart using scatter( )
import matplotlib.pyplot as plt
import numpy as np
ar2=[1,7,21,35,35,21,7,1]
#calculating sin() values
s2=np.sin(ar2)
plt.scatter(ar2,s2,marker='X')
#'X' is for big plus and observe
plt.xlabel('Array Values')
plt.ylabel('Sine Values')
plt.show()
scatter ( ) with all arguments
#plotting scatter chart using scatter( ) all arguments
import matplotlib.pyplot as plt
import numpy as np
ar1=np.linspace(-1,1,5)
ar2=np.exp(ar1)
colarr=['r','b','m','g','k']
sarr=[20,60,100,45,25]
plt.scatter(ar1,ar2,c=colarr,s=sarr)
plt.xlabel('Array Values')
plt.ylabel('EXP')
plt.show()
NOTE: ar1 &ar2 has 5 values. 5 colors and 5 different sizes
Programs practical work
• EG 8 PG 180
• EG 9 PG 181
• EG 10 PG 181
Creating Bar Charts
• A bar chart or bar graph is a chart or graph that presents categorical
data with rectangular bars with heights or lengths proportional to the
values that they represent. The bars can be plotted vertically or
horizontally.
• bar() function is used to create bar chart.
• Syntax:
plt.bar(X,Y,width=<width_val/sequence>,
color=<col_code/sequence>)
X,Y are sequence type.
Width scalar or array. Width(s) of the bars default 0.8. sequence
means different width to different bars.
Color scalar or array. Common color or different colors to different
bars.
#Program1
import matplotlib.pyplot as plt
langs = ['C', 'C++', 'Java', 'Python', 'PHP']
students = [23,17,35,29,12]
plt.bar(langs,students)
plt.xlabel('language')
plt.ylabel('No. of Students')
plt.show()
#Program2
import matplotlib.pyplot as plt
subs=['IP','MS','GEO','MATHS']
Cl_12A=[25,50,65,50]
Cl_12B=[20,10,35,45]
plt.figure(figsize=(15,7))
plt.bar(subs,Cl_12A)
plt.bar(subs,Cl_12B)
plt.xlabel('subs')
plt.ylabel('No. of Students')
plt.legend(['12A','12B'])
plt.show()
Changing width of the bar in Bar chart
• Width means thickness of bars of bar chart.
• Default width unit is 0.8 units. Means all bars have same width.
• To specify the different width of bar plot use width argument in bar()
function.
• Width values are floats.
• Default width is 0.8 units but it can be less/more then 0.8units
• Width can be change in 2 following ways:
1) By specifying a different width for all bars of bar chart.
2) By specifying a different width for different bars of bar chart i.e. using
tuple/list sequence.
1) By specifying a different width for all bars of bar chart.
#Program3
langs = ['C', 'C++', 'Java', 'Python', 'PHP']
students = [23,17,35,29,12]
plt.bar(langs,students,width=[0.5,0.6,0.8,0.9,0.6])
plt.xlabel('language')
plt.ylabel('No. of Students')
Width of all bars are
plt.show() different
Points to remember about widths of graphs
• To specify different widths for different bars use width argument
having sequence such as lists/tuple containing widths for each bar in
the bar() function.
• The widths given in the sequence are applied from left to right.
Means first width value of data to 1st sequence and so on..
• The width values are floats.
• Number of width values must match to the bars else python throws
an error. ValueError:shape mismatch error.
Programs practical work
• EG 11 PG 193
• EG 12 PG 194
• EG 13 PG 196
Changing color of the bar in Bar chart
• Default, a bar chart draws bars with same default color.
• Color code must be valid names.
• Colors can be change in 2 following ways:
1) By specifying a different color for all bars of bar chart i.e. one common color
for all bars.
2) By specifying a different colors for different bars of bar chart i.e. using
tuple/list sequence.
1) By specifying a different color for all bars of bar chart i.e. one common
color for all bars.
import matplotlib.pyplot as plt
#Program3
#common color
langs = ['C', 'C++', 'Java', 'Python', 'PHP']
students = [23,17,35,29,12]
plt.bar(langs,students,width=0.3, color=‘k’)
plt.xlabel('language')
plt.ylabel('No. of Students')
plt.show()
2) By specifying a different colors for different bars of bar chart i.e.
using tuple/list sequence.
import matplotlib.pyplot as plt
#Program
#different color for different bars
board=['CBSE','ICSE','HSC','IB']
boys=[500,300,207,250]
girls=[400,200,205,280]
br=np.arange(len(board)) #[0,1,2,3]
br1=br+0.25 #[0.25,1.25,2.25,3.25]
plt.bar(br,boys,color='r',width=0.25)
plt.bar(br1,girls,color='g',width=0.25)
plt.legend()
plt.show()
EG15 PAGE199
import matplotlib.pyplot as plt
import numpy as np
val=[[5.,25.,45.,20,],[4.,23.,49.,17.],[6.,22.,47.,19.]]
x=np.arange(4)
plt.bar(x+0.00,val[0],color='b',width=0.25)
plt.bar(x+0.25,val[1],color='g',width=0.25)
plt.bar(x+0.50,val[2],color='r',width=0.25)
plt.show()
Program
EG16 PG 200
Creating Horizontal Bar Chart
To create horizontal bar chart barh() function is used.
import matplotlib.pyplot as plt
import numpy as np
#program 1
board=['CBSE','ICSE','HSC','IB']
boys=[500,300,207,250]
girls=[400,200,205,280]
plt.barh(board,boys, color='gold')
plt.xlabel('No of Stud')
plt.ylabel('BOARD')
plt.show()
#program 2 stacked
import matplotlib.pyplot as plt
import numpy as np
board=['CBSE','ICSE','HSC','IB']
boys=[500,300,207,250]
girls=[400,200,205,230]
plt.barh(board,boys, color='gold')
plt.barh(board,girls, color='silver')
plt.xlabel('No of Stud')
plt.ylabel('BOARD')
plt.show()
#program 3
import matplotlib.pyplot as plt
import numpy as np
board=['CBSE','ICSE','HSC','IB']
boys=[500,300,207,250]
girls=[400,200,205,280]
br=np.arange(len(board)) #[0,1,2,3]`
w=0.25
plt.barh(br,boys, color='gold',height=0.25)
plt.barh(br+0.25,girls, color='silver',height=0.25)
plt.xlabel('No of Stud')
plt.ylabel('BOARD')
matplotlib.pyplot.title(<String title>)
OR
Plt.title(<String title>)
Y-axis Label
X-axis Label
Setting X and Y Labels, Limits and Ticks
matplotlib.pyplot. xlabel(<String title>)
OR
plt.xlabel(<String title>)
matplotlib.pyplot.ylim(<ymin>,<ymax>)
OR
plt.ylim(<ymin>,<ymax>)
Inclusive of min and max values
import matplotlib.pyplot as plt
import numpy as np
#Program1
X=np.arange(4) #[0,1,2,3]
Y=[5.,25.,45.,20.]
plt.xlim(-2.0,4.0)
plt.bar(X,Y)
plt.title("TITLE")
plt.show()
• NOTE: the data that falls into the limits of X and Y axes will be plotted
means rest of the data will not shown in the plot. If X and Y axes limits
are not compatible with data values then incomplete plot is visible.
import matplotlib.pyplot as plt
import numpy as np
X=np.arange(4) #[0,1,2,3]
Y=[5.,25.,45.,20.]
plt.xlim(-4.0,1.0)
plt.bar(X,Y)
plt.title("TITLE")
plt.show()
• Practical work
• EG 21 PAGE 211
Setting Ticks for Axes
• Pyplot automatically decides which data points will have ticks on the
axes.
• To set the customized X-axis and Y-axis ticks; xticks() and yticks()
functions are used.
matplotlib.pyplot.xticks(<sequenceOfDataPoints>,[tickLabelsequence])
OR
plt.xticks(<sequenceOfDataPoints>,[tickLabelsequence])
matplotlib.pyplot.yticks(<sequenceOfDataPoints>,[tickLabelsequence])
OR
plt.yticks(<sequenceOfDataPoints>,[tickLabelsequence])
import matplotlib.pyplot as plt
#Program1
q=range(4) #[0,1,2,3]
s=[23.4,25,26,8.5]
plt.xticks([0,1,2,3])
plt.bar(q,s)
plt.show()
Customized Xticks
import matplotlib.pyplot as plt
#Program2
q=range(4,8) #[4,5,6,7]
s=[23.4,25,26,8.5]
plt.xticks([0,1,2,3])
plt.bar(q,s)
plt.show()
plt.xticks([5,6,7,8])
plt.bar(q,s)
plt.show()
s=[23.4,25,26,8.5]
plt.xticks([4,5,6,7])
plt.bar(q,s)
plt.show()
#Program 3
import matplotlib.pyplot as plt
q=range(5) #[0,1,2,3,4]
langs = ['C', 'C++', 'Java', 'Python', 'PHP']
students = [23,17,35,29,12]
plt.xlabel('language')
plt.ylabel('No. of Students')
plt.title("Students for each langunge")
plt.show()
• Programs for Practical Work
• EG 22 PG 213
• EG 23 PG 213,214
• EG24 PG 214
• EG25 PG 215
ylim(min,max)
Adding Legends
• When multiple bar chart(bar())/ multiple horizontal bar(barh()) char or line
chart(plot()) is plotted then which color is for what value can be specified
through legend.
• For adding legend legend() function is used.
matplotlib.pyplot.legend(loc=<position no./string >)
OR
plt.legend(loc=<position no./string >)
• loc signifies the position i.e. 1,2,3,4 or ‘upper right’, ‘upper left’, ‘lower left’,
‘lower right’ respectively.
• Default is 1 or ‘upper right’.
import matplotlib.pyplot as plt
import numpy as np
board=['CBSE','ICSE','HSC','IB']
boys=[500,300,207,250]
girls=[400,200,205,280]
br=np.arange(len(board)) #[0,1,2,3]
br1=br+0.25 #[0.25,1.25,2.25,3.25]
plt.bar(br,boys,color='r',width=0.1)
plt.bar(br1,girls,color='g',width=0.1)
plt.legend(['boys','girls'],loc=3)
plt.xticks(br+0.125,board)
plt.show()
• Programs for Practical Work
• Solved EG PG216
• EG 26 PG216
Saving a figure
• For saving chart savfig() function is used. It can be saved in popular
formats like .pdf, .png, .eps etc.
• Syntax:
matplotlib.pyplot.savefig(<string filename with path>)
OR
plt. savefig(<string filename with path>)
EG: plt.savefig(“BARCART.pdf”) will save plot in current directory
plt.savefig(“C:\\charts\\BARCART.pdf”) will save plot in specified directory
#Program 1
import matplotlib.pyplot as plt
import numpy as np
board=['CBSE','ICSE','HSC','IB']
boys=[500,300,207,250]
girls=[400,200,205,280]
br=np.arange(len(board)) #[0,1,2,3]
br1=br+0.25 #[0.25,1.25,2.25,3.25]
plt.bar(br,boys,color='r',width=0.1)
plt.bar(br1,girls,color='g',width=0.1)
plt.legend(board,loc=3)
plt.xticks(br+0.125,board)
plt.show()
plt.savefig("BARCHART.pdf")
Creating Histogram with Pyplot
• A histogram is an accurate representation of the distribution of
numerical data. It is an estimate of the probability distribution of
a continuous variable. It is a kind of bar graph.
• Histogram needs only single dimension array i.e. x axis and y axis
contains the frequency on values.
• A histogram is a summarisation tool for discrete or continuous data.
• To construct a histogram, follow these steps −
Bins the range of values.
Divide the entire range of values into a series of intervals.
Count how many values fall into each interval.
• The bins are usually specified as consecutive, non-overlapping
intervals of a variable.
• The matplotlib.pyplot.hist() function plots a histogram.
• Syntax:
matplotlib.pyplot.hist(x, bins=None, cumulative=False,
histtype=‘bar’, align =‘mid’, orientation=‘vertical’)
x- array or sequence of arrays
bins - integer or sequence. It is optional. If integer given, bins+1
bin-edges are calculated and returned. Default value is
automatically provided i.e. internally. In short bins divide the
entire range of values into a series of intervals and then count
how many values fall into each interval. EG
cumulative- has Boolean value. Its optional. If True, then a histogram is
computed where each bin gives the counts in that bin plus all bins for
smaller values. The last bin gives the total number of datapoints. Default
is False.
histtype: The type of histogram to draw. Default is ‘bar’.
• ‘bar’ is a traditional bar-type histogram. If multiple data are given the
bars are arranged side by side.
• ‘barstacked’ is a bar-type histogram where multiple data are stacked on
top of each other.
• ‘step’ generates a lineplot that is by default unfilled.
• ‘stepfilled’ generates a lineplot that is by default filled.
align : This parameter is an optional parameter and it controls how the
histogram is plotted. ‘left’, ‘mid’, ‘right’
orientation: this parameter is optional. It is used to plot the ‘horizontal’ or
‘vertical’ graph. If ‘horizontal’, barh() function will be used
import matplotlib.pyplot as plt
#Program1
students = [23,17,35,29,12,24,45,56,44,44]
plt.hist(students,bins=5)
plt.xlabel('language')
plt.ylabel('No. of Students')
plt.show()
y=np.random.randn(1000)
#plt.hist(y)
#plt.hist(y,bins=25)
#plt.hist(y,bins=50)
#plt.hist(y,bins=25,edgecolor="red") #border color red
#plt.hist(y,bins=25,cumulative=True)
#plt.hist(y,bins=25, histtype='step’) #will plot a steps of graph
plt.hist(y,bins=25, color='gold',histtype='step’) #graph steps color gold
plt.hist(y,bins=25, color='gold’) #graph color gold/yellow
plt.show()
import matplotlib.pyplot as plt
import numpy as np
y=np.random.randn(1000)
x=np.random.randn(1000)
plt.hist([x,y],bins=25,cumulative=True, histtype='barstacked')
plt.show()
import matplotlib.pyplot as plt
import numpy as np
y=np.random.randn(1000)
x=np.random.randn(1000)
plt.hist(x,bins=25,cumulative=True, histtype='stepfilled’)
plt.show()
import matplotlib.pyplot as plt
import numpy as np
y=np.random.randn(1000)
x=np.random.randn(1000)
plt.hist(y,bins=50, orientation='horizontal')
plt.show()
import matplotlib.pyplot as plt
import numpy as np
y=np.random.randn(1000)
x=np.random.randn(1000)
plt.hist(y,bins=25,align='right',color='grey') #align='right'/'mid'/'left’
plt.show()
Extra practical questions
1. Create an array of integers of 30 nos between 5 and 35. Draw histogram
having 10 bins and red color.
2. Create an array of integers of 30 nos between 5 and 35. Draw
cumulative histogram having 10 bins and red color.
3. Create an array of integers of 30 nos between 5 and 35. Draw
cumulative histogram having 10 bins and showing histogram border.
[HINT: histtype=‘step’+
4. Create an array of integers of 30 nos between 1 and 50. Create another
array of 30 integers between 5 and 35. Draw histogram showing the
histogram of both arrays, in the same plot. The histogram must be
cumulative True barstacked.
5. Change the orientation of above histogram to horizontal.
Plotting Data from a Dataframe
Data=pd.read_csv("DF1.csv")
print(Data)
df_new=Data[['Age','Pojects','Budget']]
print(df_new)
plt.bar(df_new.index,df_new.Age) #single bar graph
Plt.show()
import matplotlib.pyplot as plt
import pandas as pd
#program 3plotting multiple bar chart
Data=pd.read_csv("DF1.csv")
print(Data)
df_new=Data[['Age','Pojects','Budget']]
print(df_new)
plt.bar(df_new.index,df_new.Age, color='r', width=0.5)
plt.bar(df_new.index+0.5,df_new.Pojects, color='g', width=0.5)
plt.xticks(df_new.index+0.125,Data.Name)
plt.show()
Plotting a DF’s Data using DF’s plot()
• Pandas provide a function plot() which you can use with DF as:
<DF>.plot()
This function will plot the data of the DF automatically i.e. it takes all
numeric data to plot the graph.
DF’s plot() uses the kind parameter for plotting the kind of graph.
kind=‘line’ / ‘bar’ / ‘barh’ / ‘hist’
It is an optional parameter. If no value specified than by default line
graph is plotted.
import matplotlib.pyplot as plt
import pandas as pd
Data=pd.read_csv("DF1.csv")
print(Data)
#Data.plot() #default is line
#Data.plot(kind='line')
#Data.plot(kind='bar')
#Data.plot(kind='barh')
Data.plot(kind='hist')
plt.show()
import matplotlib.pyplot as plt
import pandas as pd
#program2 plotting graph using df and reading csv file
Data=pd.read_csv("DF1.csv")
print(Data)
x=Data.loc[0:3,'Age':'Pojects']
print(x)
x.plot() #default is line
plt.show()