Eda Lab Record Anna University
Eda Lab Record Anna University
To generate basic visualizations (scatter plot, histogram, box plot, and bar plot) using the Iris dataset
with matplotlib in Python.
ALGORITHM:
1. Import necessary libraries: Use matplotlib for plotting and pandas for data handling.
4. Create a scatter plot: Use plt.scatter() to plot Sepal Length vs Sepal Width.
PROGRAM:
import pandas as pd
iris = pd.read_csv('iris.csv')
print(iris.head())
plt.figure(figsize=(8, 5))
plt.grid(True)
plt.show()
plt.figure(figsize=(8, 5))
plt.grid(True)
plt.show()
plt.figure(figsize=(8, 5))
plt.show()
species_count = iris['species'].value_counts()
plt.figure(figsize=(8, 5))
plt.xlabel('Species', fontsize=12)
plt.ylabel('Count', fontsize=12)
plt.xticks(rotation=0)
plt.grid(axis='y')
plt.show()
OUTPUT:
SUMMA CODE:
import matplotlib.pyplot as plt
# Histogram
plt.title('Histogram')
plt.xlabel('Values')
plt.ylabel('Frequency')
plt.show()
# Box Plot
plt.title('Box Plot')
plt.ylabel('Values')
plt.show()
# Scatter Plot
x = [1, 2, 3, 4, 5]
y = [5, 7, 8, 6, 9]
plt.scatter(x, y, color='blue')
plt.title('Scatter Plot')
plt.xlabel('X')
plt.ylabel('Y')
plt.show()
# Bar Plot
values = [3, 7, 4, 6]
plt.title('Bar Plot')
plt.xlabel('Categories')
plt.ylabel('Values')
plt.show()
Result: Various plots such as a scatter plot of Sepal Length vs Sepal Width, a histogram of Petal
Length, a box plot of Sepal Width, and a bar plot of species count are displayed to visualize the
dataset's characteristics.