CH 3 Data Visualization
CH 3 Data Visualization
Basics of plotting
There are various types of chart we can use to visualize the data elements like:
Line chart: it displays information as a series of data points called markers connected by straight
line
Bar chart it were present category wise data in rectangular bars with length proportional to the
values it can be horizontal and vertical.
Histogram:
53
❖ Setting up the labels in X and Y axis
Function used :
xlabel()
ylabel()
❖ Setting up the title for the chart
Function used :
title()
54
Bar Graph
A bar graph is used to represent data in the form of vertical or horizontal bars it is useful to compare
the quantities
Function used :
bar()
55
❖ Changing Width, color in bar chart
Parameters in the bar function
❖ Width
56
❖ color
57
❖ Adding legends in Graphs
Function used :
o Legend()
58
❖ Setting Limits to X-axis and Y axis
Functions used
o xlim()
o ylim()
59
❖ Setting ticks for bar graph
Functions used
o xticks()
o yticks()
Histogram
• Distribution of values.
• It shows how the values are grouped into different intervals or bins.
Functions used
hist()
60
Worksheet for Data Visualization
1 …………………is the function used to set the limits for X axis.
a) xlimit() b) xLim() c)lim() d) xlim()
2 ………………………………… is the library used for data visualization in python
3 The plot which tells the trend between two graphed variable is ………………
4 Which argument of bar() lets you set the thickness of bar?
5 Which argument must be set in the plotting function for legend() to display the legend?
a) show b) label c) name d) seq
6 …….. is a summarization tool for discrete or continuous data.
a)
7 ……………….method is used to create a histogram from a dataframe in pandas.
8 Explain the use of barh() function.
9 Which argument of bar() lets you set the thickness of bar?
10 What do you mean by legends?
11 What do you mean by marker style and markersize in plot() function.
12 What will be the output of the following code :
61
import matplotlib.pyplot as plt
plt.plot([1,2,3],[4,5,1])
plt.show()
16 Given two arrays namely arr1 and arr2 each having 5 values. Write a program to create
a Line chart so that each data points gets a different color, different size. Keep the
marker style as Diamond.
17 Write the Python program to create a histogram on the list named height containing
height of students. Use necessary functions to give the title, label, legend etc
Height=[167,158,150,140,130,145,146,128,162,153,165,133,144,122,138]
62