0% found this document useful (0 votes)
30 views3 pages

Data Visulization Notes

The document discusses various functions and arguments that can be used to customize matplotlib plots in Python. It provides examples of creating a bar graph using Pandas and matplotlib to visualize CSV data. It also provides an example of creating a histogram to represent the frequency of weights of students.

Uploaded by

tushan
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)
30 views3 pages

Data Visulization Notes

The document discusses various functions and arguments that can be used to customize matplotlib plots in Python. It provides examples of creating a bar graph using Pandas and matplotlib to visualize CSV data. It also provides an example of creating a histogram to represent the frequency of weights of students.

Uploaded by

tushan
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 VISULIZATION

Some Pyplot functions to customise plots:

• grid() Configure the grid lines.


• legend() Place a legend on the axes.
• Savefig() Save the current figure.
• show() Display all figures.
• title() Set a title for the axes.
• xlabel() Set the label for the x-axis.
• xticks() get or set the current tick locations and labels of the x-axis.
• ylabel() Set the label for the y-axis.
• yticks() Get or set the current tick locations and labels of the y-axis.

Some Pyplot arguments to customise plots:

• line
• marker
• color
• linestyle
• linewidth
• markersize

# Bar Graph

import matplotlib.pyplot as plt

std = [9,10,11,12]

strength = [50,55,45,60]

plt.bar(std,strength,color='m')

plt.savefig('E:/12C2022/graph1.jpg')

plt.xticks(std,color='g')

plt.yticks([0,20,40,60])

plt.grid()

plt.show()
# using CSV (comma separated value) file

import pandas as pd

df = pd.DataFrame(pd.read_csv('marks.csv'))

'''

Name Math Phy Che

0 Amit 67 76 88

1 Sumit 80 65 76

2 Jeet 78 60 90

'''

df.plot(kind='bar',x='Name')

df.plot()

OR

df.plot(kind=’line’)

1. Create a histogram to represent the frequency of weight of 50


students of class 11 and 12.

Ans:

w11 = [78, 47, 59, 66, 47, 72, 80, 50, 41, 67, 60, 61, 68, 52,
47, 61, 79, 65, 69, 44, 52, 42, 56, 40, 63, 67, 41, 60,
42, 60, 77, 54, 58, 56, 59, 73, 48, 71, 68, 67, 74, 44,
70, 49, 79, 52, 52, 67, 75, 43, 60, 75, 55, 41, 54, 74,
62, 80, 71, 76]

w12 = [77, 76, 78, 74, 63, 66, 54, 76, 56, 53, 44, 75, 59, 71,
50, 77, 45, 40, 72, 62, 44, 71, 41, 63, 47, 44, 78, 43,
58, 60, 45, 40, 67, 76, 46, 45, 69, 53, 66, 49, 58, 46,
66, 65, 74, 55, 72, 71, 66, 75, 41, 74, 74, 57, 54, 52,
79, 65, 42, 76]

plt.hist([w11,w12],bins=[40,50,60,70,80])
plt.xlabel('Weight (in Kg)')
plt.ylabel('No. of Students')
plt.show()

You might also like