XII IP CH 3 Plotting With Pyplot
XII IP CH 3 Plotting With Pyplot
XII IP CH 3 Plotting With Pyplot
Data Visualization
Data visualization refers to the graphical or
visual representation of information and data
using visual elements like charts, graphs, and
maps, etc.
OR
import matplotlib.pyplot as pl
Line Chart
A line chart or line plot or line graph is a type of
chart which displays information as a series of
data points called 'markers' connected by
straight line segments.
Bar Chart
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.
Histogram
• A histogram is a plot that
lets you discover, and
show, the underlying
frequency distribution
(shape) of a set of
continuous data.
'r' red
'g' green
'b' blue
'm' magenta
'y' yellow
'k' black
'c' cyan
'w' white
Changing Line Style
linestyle or ls = [ 'solid' | 'dashed' | 'dashdot' | 'dotted' ]
import matplotlib.pyplot as pl
pl.plot( A , B , 'r' , ls='dotted' )
pl.xlabel("2019")
pl.ylabel("Price in Rs.")
pl.show()
Changing Marker Type, Size and Color
marker=<value>, markersize=<points>, markeredgecolor=<color>
pl.savefig("chart.pdf")
pl.savefig("d:\\python\\chart.png")
Creating Histogram
• A histogram is a plot that lets you discover, and show, the
underlying frequency distribution (shape) of a set of
continuous data.
• Unlike the bar chart, there are no gaps between the bars,
although some bars might be "absent" reflecting no
frequencies.
hist() function
• This function of pyplot is used to create histograms.
df=pd.DataFrame({'Name':['Vijaya','Rahul','Meghna', 'Radhika','Shourya'],
'Marks':[80,92, 67, 95,97],
'Age':[32, 28, 30, 25, 20]})
print(df)