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

PlotsPython - Ipynb - Colab

The document provides a Python script for visualizing the Iris dataset using various plots, including line, scatter, histogram, bar, box, violin, KDE, heatmap, pair plot, area plot, and pie chart. It uses libraries such as pandas, matplotlib, and seaborn to load the data and create visualizations. Additionally, it demonstrates interactive visualizations using Plotly for scatter and line charts.

Uploaded by

shreya.singh2025
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 views4 pages

PlotsPython - Ipynb - Colab

The document provides a Python script for visualizing the Iris dataset using various plots, including line, scatter, histogram, bar, box, violin, KDE, heatmap, pair plot, area plot, and pie chart. It uses libraries such as pandas, matplotlib, and seaborn to load the data and create visualizations. Additionally, it demonstrates interactive visualizations using Plotly for scatter and line charts.

Uploaded by

shreya.singh2025
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

3/7/26, 8:22 AM PlotsPython.

ipynb - Colab

import pandas as pd
import numpy as np
import [Link] as plt
import seaborn as sns

# Set style
[Link](style="whitegrid")

# ==========================
# LOAD DATA
# ==========================

df = pd.read_csv('[Link]')

print("Dataset Shape:", [Link])


print([Link]())

# ==========================
# 1. LINE PLOT
# ==========================
[Link](figsize=(8,6),facecolor='lightblue')
[Link](df['sepal_length'], label='Sepal Length')
[Link]("Line Plot - Sepal Length")
[Link]("Index")
[Link]("Value")
[Link]([Link](0,150,10))
[Link]()
[Link]()

# ==========================
# 2. SCATTER PLOT
# ==========================
[Link](figsize=(8,6))
[Link](x='sepal_length', y='sepal_width', hue='species', data=df)
[Link]("Scatter Plot")
[Link]()
# ==========================
# 3. HISTOGRAM
# ==========================
[Link](figsize=(8,5))
[Link](df['petal_length'], bins=20, color='skyblue')
[Link]("Histogram - Petal Length")
[Link]("Petal Length")
[Link]()

# ==========================
# 4. BAR PLOT
# ==========================
[Link](figsize=(8,5))
[Link](x='species', y='sepal_length', data=df)
[Link]("Bar Plot")
[Link]()

# ==========================
# 5. BOX PLOT
# ==========================
[Link](figsize=(8,6))
[Link](x='species', y='petal_length', data=df)
[Link]("Box Plot")
[Link]()

# ==========================
# 6. VIOLIN PLOT
# ==========================
[Link](figsize=(8,6))
[Link](x='species', y='petal_width', data=df)
[Link]("Violin Plot")
[Link]()

# ==========================
# 7. KDE PLOT
# ==========================
[Link](figsize=(8,6))
[Link](df['sepal_length'], shade=True, color="r")
[Link](df['sepal_width'], shade=True, color="g")
lt titl ("K l D it E ti t (KDE)")
[Link] 1/4
3/7/26, 8:22 AM [Link] - Colab
[Link]("Kernel Density Estimate (KDE)")
[Link](['Sepal Length', 'Sepal Width'])
[Link]()

# ==========================
# 8. HEATMAP
# ==========================
[Link](figsize=(8,6))
corr = [Link]()
[Link](corr, annot=True, cmap="coolwarm")
[Link]("Correlation Heatmap")
[Link]()

# ==========================
# 9. PAIR PLOT
# ==========================
[Link](df, hue="species")
[Link]("Pair Plot of Variables", y=1.02)
[Link]()

# ==========================
# 10. AREA PLOT
# ==========================
[Link](figsize=(8,6))
df[['sepal_length','sepal_width']].[Link](alpha=0.4)
[Link]("Area Plot")
[Link]()

# ==========================
# 11. PIE CHART
# ==========================
[Link](figsize=(6,6))
df['species'].value_counts().[Link](autopct='%1.1f%%')
[Link]("Pie Chart of Species")
[Link]("")
[Link]()

[Link] 2/4
3/7/26, 8:22 AM [Link] - Colab

Dataset Shape: (150, 5)


sepal_length sepal_width petal_length petal_width species
0 5.1 3.5 1.4 0.2 setosa
1 4.9 3.0 1.4 0.2 setosa
2 4.7 3.2 1.3 0.2 setosa
3 4.6 3.1 1.5 0.2 setosa
4 5.0 3.6 1.4 0.2 setosa

vimport pandas as pd
import [Link] as px

# Load dataset
url = "[Link]
df = pd.read_csv(url)

# Simple scatter plot


fig = [Link](
df,
x='sepal_length',
y='sepal_width',
color='species', # color by species
size='petal_length', # size by petal length
hover_data=['petal_width'] # additional info on hover
)

fig.update_layout(
title="Iris Dataset Scatter Plot",
xaxis_title="Sepal Length",
yaxis_title="Sepal Width"
)

[Link]()

[Link] 3/4
3/7/26, 8:22 AM [Link] - Colab

df['index'] = [Link]
fig = [Link](
df,
x='index',
y='sepal_length',
color='species', # color by species
markers=True # show points on the line
)

fig.update_layout(
title="Interactive Line Chart - Sepal Length",
xaxis_title="Index",
yaxis_title="Sepal Length"
)

[Link]()

Iris Dataset Scatter Plot

4.5

3.5
Sepal Width

2.5

4.5 5 5.5 6 6.5 7 7.5

Sepal Length

Interactive Line Chart - Sepal Length

75

[Link] 4/4

You might also like