0% found this document useful (0 votes)
36 views16 pages

Data Science

Notes of Data Visualization

Uploaded by

tsudiksha23cs
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)
36 views16 pages

Data Science

Notes of Data Visualization

Uploaded by

tsudiksha23cs
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

Name: Ronit Manoj Thakur

Class: SY IT B
Roll no.: 5568
Name: Ronit Manoj Thakur
Class: SY IT B
Roll no.: 5568
PRACTICAL 1
1. Plot a Simple histogram and bar plot and apply various customization
techniques.
CODE:
import [Link] as plt
data = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]
[Link](data, bins=4, color='white', edgecolor='black', alpha=0.7)
[Link]('Value')
[Link]('Frequency')
[Link]('Simple Histogram with Customizations (IT B 5568)')
[Link](False)
[Link]()
OUTPUT:
Name: Ronit Manoj Thakur
Class: SY IT B
Roll no.: 5568
B. barplot:
CODE:
import [Link] as plt
categories = ['A', 'B', 'C', 'D']
values = [5, 7, 3, 8]
[Link](categories, values, color='black', edgecolor='black')
[Link]('Category')
[Link]('Value')
[Link]('Simple Bar Plot with Customizations (IT B 5568)')
[Link](axis='y')
[Link]()
OUTPUT:
Name: Ronit Manoj Thakur
Class: SY IT B
Roll no.: 5568
C. Seaborn Histogram with KDE
CODE:
import seaborn as sns
import [Link] as plt
data = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]
[Link](data, bins=4, kde=True, color='white',alpha=0.3)
[Link]('Value')
[Link]('Frequency')
[Link]('Seaborn Histogram with KDE (IT B 5568)')
[Link]()
OUTPUT:
Name: Ronit Manoj Thakur
Class: SY IT B
Roll no.: 5568
D.
CODE:
import seaborn as sns
import [Link] as plt
categories = ['A', 'B', 'C', 'D']
values = [5, 7, 3, 8]
[Link](x=categories, y=values, hue=categories, palette='Blues')
[Link]('Category')
[Link]('Value')
[Link]('Seaborn Bar Plot with Customizations (IT B 5568)')
[Link]()
OUTPUT:
Name: Ronit Manoj Thakur
Class: SY IT B
Roll no.: 5568

E. Pandas Histogram with Customization


CODE:
import pandas as pd
import [Link] as plt
data = [Link]([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])
[Link](kind='hist', bins=4, color='black', edgecolor='black', alpha=0.7)
[Link]('Value')
[Link]('Frequency')
[Link]('Pandas Histogram with Customizations (IT B 5568)')
[Link]()
OUTPUT:
Name: Ronit Manoj Thakur
Class: SY IT B
Roll no.: 5568
F. Pandas barplot with Customizations
CODE:
import pandas as pd
import [Link] as plt
data = [Link]([5, 7, 3, 8], index=['A', 'B', 'C', 'D'])
[Link](kind='bar', color='white', edgecolor='black')
[Link]('Category')
[Link]('Value')
[Link]('Pandas Bar Plot with Customizations (IT B 5568)')
[Link]()
OUTPUT:
Name: Ronit Manoj Thakur
Class: SY IT B
Roll no.: 5568
G. Plotly Histogram with Customizations
CODE:
import [Link] as px
data = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4,6,7,8,8,9,10]
fig = [Link](data, title='Plotly Histogram with Customizations (IT B 5568)',opacity=0.2)
fig.update_traces(marker_color='white', marker_line_color='black', marker_line_width=1.5)
[Link]()
OUTPUT:
Name: Ronit Manoj Thakur
Class: SY IT B
Roll no.: 5568
H. Plotly Barplot with Customizations
CODE:
import [Link] as px
categories = ['A', 'B', 'C', 'D']
values = [5, 7, 3, 8]
fig = [Link](x=categories, y=values, title='Plotly Bar Plot with Customizations (IT B 5568)',
labels={'x':'Category', 'y':'Value'})
fig.update_traces(marker_color='white', marker_line_color='black', marker_line_width=3)
[Link]()
OUTPUT:
Name: Ronit Manoj Thakur
Class: SY IT B
Roll no.: 5568
PRACTICAL 2
1. Create a simple plot and add ticks, labels, axes
A. SCATTER PLOT
CODE:
import [Link] as plt
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
fig, ax = [Link]()
[Link](x, y, color='black')
ax.set_xlabel('X-as')
ax.set_ylabel('Y-axis')
ax.set_title('Simple Scatter Plot (IT B 5568)')
ax.set_xticks([1, 3, 5])
ax.set_yticks([2, 6, 10])
ax.set_xlim(0, 6)
ax.set_ylim(0, 9)
[Link]()
OUTPUT:
Name: Ronit Manoj Thakur
Class: SY IT B
Roll no.: 5568
B. Bar plot
CODE:
import [Link] as plt
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
fig, ax = [Link]()
[Link](x, y, color='black')
ax.set_xlabel('X-axis')
ax.set_ylabel('Y-axis')
ax.set_title('Simple Bar Plot (IT B 5568)')
ax.set_xticks([1, 3, 5])
ax.set_yticks([2, 6, 10])
ax.set_xlim(0, 6)
ax.set_ylim(0, 15)
[Link]()
OUTPUT:
Name: Ronit Manoj Thakur
Class: SY IT B
Roll no.: 5568
PRACTICAL 3
1. Plot Strip plot, Box Plot, Swarm plot, Joint plot, on Tips dataset.
a. Strip Plot of Total Bill by Day
CODE:
import seaborn as sns
import [Link] as plt
# Load the dataset
tips = sns.load_dataset('tips')
# Display the first few rows of the dataset
print([Link]())
# Create a strip plot
[Link](figsize=(8, 6))
[Link](x='day', y='total_bill', data=tips)
[Link]('Strip Plot of Total Bill by Day (IT B 5568)')
[Link]('Day')
[Link]('Total Bill')
[Link]()
OUTPUT:
Name: Ronit Manoj Thakur
Class: SY IT B
Roll no.: 5568
b. Box plot
CODE:
[Link](figsize=(8, 6))
[Link](x='day', y='total_bill', data=tips)
[Link]('Box Plot of Total Bill by Day (IT B 5568)')
[Link]('Day')
[Link]('Total Bill')
[Link]()
OUTPUT:
Name: Ronit Manoj Thakur
Class: SY IT B
Roll no.: 5568
c. Swarm plot:
CODE:
[Link](figsize=(8, 6))
[Link](x='day', y='total_bill', data=tips)
[Link]('Swarm Plot of Total Bill by Day (IT B 5568)')
[Link]('Day')
[Link]('Total Bill')
[Link]()
OUTPUT:
Name: Ronit Manoj Thakur
Class: SY IT B
Roll no.: 5568
d. Joint plot
CODE:
[Link](x='total_bill', y='tip', data=tips, kind='hex')
[Link]('Joint Plot of Total Bill and Tip (IT B 5568)', y=1.03)
[Link]()
OUTPUT:
Name: Ronit Manoj Thakur
Class: SY IT B
Roll no.: 5568
PRACTICAL 5
1. To add legend and annotation to the graph
CODE:
import [Link] as plt
import numpy as np
fig, ax = [Link]()
x = [1, 2, 3, 4, 5]
y = [10, 20, 25, 30, 40]
[Link](x, y)
[Link]('Annotation Text', xy =(3 ,25),
xytext =(2,38),
arrowprops = dict
(facecolor ='orange',
shrink = 0.2 , lw=2 ))
[Link]('Annotation (IT B 5568)')
[Link]()
OUTPUT:

You might also like