0% found this document useful (0 votes)
0 views2 pages

Python Matplotlib Practicals

Uploaded by

kshitijasingh24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views2 pages

Python Matplotlib Practicals

Uploaded by

kshitijasingh24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

import matplotlib.

pyplot as plt

import numpy as np

# Sample Data

employees = ['Alice', 'Bob', 'Charlie', 'David', 'Eva']

salaries = [50000, 60000, 55000, 70000, 65000]

# 1. Bar Chart

plt.figure(figsize=(10, 5))

plt.bar(employees, salaries, color='skyblue')

plt.title('Employee Salaries - Bar Chart')

plt.xlabel('Employees')

plt.ylabel('Salary ($)')

plt.grid(axis='y', linestyle='--')

plt.tight_layout()

plt.show()

# 2. Histogram (Salary Distribution)

plt.figure(figsize=(10, 5))

plt.hist(salaries, bins=5, color='green', edgecolor='black')

plt.title('Salary Distribution - Histogram')

plt.xlabel('Salary ($)')

plt.ylabel('Number of Employees')

plt.grid(axis='y', linestyle='--')

plt.tight_layout()

plt.show()

# 3. Pie Chart (Share of Total Payroll)

plt.figure(figsize=(8, 8))

plt.pie(salaries, labels=employees, autopct='%1.1f%%', startangle=140)

plt.title('Payroll Distribution - Pie Chart')


plt.tight_layout()

plt.show()

You might also like