0% found this document useful (0 votes)
11 views

CH 3 Data Visualization

Uploaded by

Kushagra Karan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

CH 3 Data Visualization

Uploaded by

Kushagra Karan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Data Visualization

• Representing the data in the form of pictures or graph


• Represents patterns and trends in data which helps the decision makers
• Matplotlib is the python library used for this.
• Pyplot is a submodule
• Constructs 2D plots

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:

Line chart or line graph


Line graph is a symbol graph that shows the result in form of lines to create a line graph we need X
and Y co-ordinate.
Function used :
Plot()
Example:

53
❖ Setting up the labels in X and Y axis
Function used :
xlabel()
ylabel()
❖ Setting up the title for the chart
Function used :
title()

❖ Display the graph


Function used :
show()

❖ Save the graph as an image


Function used :
Savefig(filename)

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

Horizontal bar graph


Function used :
Barh() is used to draw horizontal bar graph.

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()

13 What is data visualization? What is its significance?


14 Write a Python program to draw a line as shown below using given axis values with
suitable label in the x axis , y axis and a title.

15 Write the Code for the bar chart given.

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

You might also like