0% found this document useful (0 votes)
2 views6 pages

Data Visualisation Examples

The document provides various examples of data visualization techniques using matplotlib in Python, including line graphs, bar graphs, horizontal bar graphs, and histograms. It demonstrates how to plot temperature variations, cricket scores, car sales, and questionnaire responses, along with explanations of different attributes for customizing the graphs. Additionally, it includes code snippets for creating these visualizations and saving them as image files.

Uploaded by

mrr1104
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)
2 views6 pages

Data Visualisation Examples

The document provides various examples of data visualization techniques using matplotlib in Python, including line graphs, bar graphs, horizontal bar graphs, and histograms. It demonstrates how to plot temperature variations, cricket scores, car sales, and questionnaire responses, along with explanations of different attributes for customizing the graphs. Additionally, it includes code snippets for creating these visualizations and saving them as image files.

Uploaded by

mrr1104
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

#Data Visualisation

'''Line Graph - used for reperesenting trends over a period of time'''

#Question 1 - Draw a line graph to show the variation of temperature on 5


days

'''import [Link] as plt

days=['23/07','24/07','25/07','26/07','27/07']

temp=[35,31,29,34,32]

[Link](days,temp)#to generate line graph

[Link]("Days")#used to give title for x axis

[Link]("Temperature")#used to give title for y axis

[Link]("Temperature for 5 days")#used to give title

[Link]("[Link]")#used to save the graph

[Link](temp)

[Link]()'''

#To give color for the line graph along with few other attributes

'''import [Link] as plt

days=['23/07','24/07','25/07','26/07','27/07']

temp=[35,31,29,34,32]

[Link](days,temp,color="r",marker='*',linestyle='dashed',linewidth=2)

[Link]("Days")

[Link]("Temperature")

[Link]("Temperature for 5 days")


[Link]()'''

'''Note:

color - specifies the color of the line

marker - specifies a symbol that should appear at the intersecting point

linestyle - the style of line such as dotted, dashed, dashdot

linewidth - specifies the width or thickness of the line'''

#Drawing two line graphs

'''Draw a line graph showing the score by India and Australia in a cricket
match'''

'''import [Link] as plt

over=[10,20,30,40,50]

India=[56,78,65,67,71]

Aus=[78,76,35,54,43]

[Link](over,India,color='r',label="India")

[Link](over,Aus,color='g',label="Australia")

[Link]("Over")

[Link]("Runs")

[Link]("ICC Cricket")

[Link]()

[Link]()'''
'''Note:

if you want to display legends, then use the function [Link]() and also

include the attribute 'label' in the [Link]() method'''

#Bar graph - used for comparison over a period of time

#Draw a bar graph showing the sales of various car companies in the year 2023

'''import [Link] as plt

car=['maruti','hyundai','tata','mahindra','bmw']

sales=[3500,2200,2900,2400,1500]

[Link](car,sales,color=['r','g','y','m','k'])

[Link]("Company")

[Link]("Sales")

[Link]("Sales in 2023")

[Link]()'''

#Attributes of bar graph

'''import [Link] as plt

car=['maruti','hyundai','tata','mahindra','bmw']

sales=[3500,2200,2900,2400,1500]

[Link](car,sales,linestyle='dashed',edgecolor='r',linewidth=4,width=0.5)
[Link]("Company")

[Link]("Sales")

[Link]("Sales in 2023")

[Link]()'''

'''Note:

edgecolor= specifies the color for the line border

linewidth - thickness of the border

linestyle - style of the border line like dot,dash,dashdot

width - specifies the width of the bars'''

#Horizontal bar graph

'''import [Link] as plt

car=['maruti','hyundai','tata','mahindra','bmw']

sales=[3500,2200,2900,2400,1500]

[Link](car,sales)

[Link]("Sales")

[Link]("Company")

[Link]("Sales in 2023")

[Link]()'''

#Histogram - similar to bar graph. used to represent the frequency of data i.e
#how many times particluar values are repeating

'''import [Link] as plt

L=[25,26,27,25,21,25,23,24,25,26,23,23,24,25,21,20,29,28,29,20]

[Link](L,color='r',bins=3)

[Link]("Age")

[Link]("Count")

[Link]("Ages of students")

[Link]()'''

#Question 1 - 04-09-2024

import [Link] as plt

L1=['07/11','08/11','09/11','10/11']

L2=[30.0,32.0,28.0,31.0]

[Link](L1,L2,label="Date wise temperature")

[Link]("Date")

[Link]("Temperature")

[Link]("Data Temperature Line graph")

[Link]()

[Link]()

#Question 2 - 04-09-2024

import [Link] as plt


L1=["Strongly agree","Agree","Neutral","Disagree","Strongly disagree"]

L2=[8,6,10,7,5]

[Link](L1,L2)

[Link]("5 Point Likert Scale")

[Link]("[Link] responses")

[Link]("Questionnaire Responses")

[Link]("[Link]")

[Link]()

#Question 8 - 04-09-2024

import [Link] as plt

L1=[2018,2019,2020,2021,2022]

L2=[90,98,94,96,95]

[Link](L1,L2,color='g')

[Link]("year")

[Link]("pass percentage")

[Link]("result analysis")

[Link]("[Link]")

[Link]()

You might also like