0% found this document useful (0 votes)
0 views

10 Exp Python

The document outlines an experiment for students at Mahatma Gandhi Mission's College of Engineering and Technology, focusing on data visualization using Python. It includes objectives, source code for various plot types (line, scatter, bar, histogram, and pie charts), and a conclusion emphasizing the implementation of these programs. The experiment is part of the Computer Science and Engineering curriculum for the academic year 2024-25.

Uploaded by

shubham
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

10 Exp Python

The document outlines an experiment for students at Mahatma Gandhi Mission's College of Engineering and Technology, focusing on data visualization using Python. It includes objectives, source code for various plot types (line, scatter, bar, histogram, and pie charts), and a conclusion emphasizing the implementation of these programs. The experiment is part of the Computer Science and Engineering curriculum for the academic year 2024-25.

Uploaded by

shubham
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

‭Mahatma Gandhi Mission's College of Engineering and Technology‬

‭Department of Computer Science and Engineering (AIML &DS)‬

‭Academic Year 2024-25(Even Sem)‬

‭Experiment No. 10‬

‭Name of Student‬ ‭Shyamdin Prajapati‬

‭Roll No‬ ‭55‬

‭DOP‬ ‭DOS‬ ‭Marks/Grade‬ ‭Signature‬

‭ im:‬‭Write python programs to understand Data visualization‬


A
‭Objective:‬ ‭∙ To study Data visualization using python.‬
‭Outcome:‬‭Students will be able to understand Data visualization.‬

‭i) WAP to implement different types of plots using Numpy and Matplotlob‬

‭Source Code:‬

i‭mport numpy as np‬


‭import matplotlib.pyplot as plt‬

#‭ Line plot with two datasets‬


‭x = [1, 2, 3, 4, 5]‬
‭y1 = [1, 4, 9, 16, 25]‬
‭y2 = [2, 3, 5, 7, 11]‬
‭plt.figure(figsize=(6, 5))‬
‭plt.plot(x, y1, color='green', linestyle='-', marker='o', label='Dataset 1')‬
‭plt.plot(x, y2, color='red', linestyle='--', marker='s', label='Dataset 2')‬
‭plt.xlabel('X-axis')‬
‭plt.ylabel('Y-axis')‬
‭plt.title('Simple Plot with Two Datasets')‬
‭plt.legend()‬
‭plt.annotate('Point‬ ‭(3,‬ ‭9)',‬ ‭xy=(3,‬ ‭9),‬ ‭xytext=(4,‬ ‭10),‬ ‭arrowprops=dict(facecolor='blue',‬
‭arrowstyle='->'))‬
‭plt.show()‬

#‭ Scatter plot example‬


‭x = [1, 2, 3, 4, 5]‬
‭y = [1, 4, 9, 16, 25]‬
‭plt.scatter(x, y, color='blue', marker='o', label='Dataset')‬
‭plt.xlabel('X-axis')‬
‭plt.ylabel('Y-axis')‬
‭plt.title('Simple Scatter Plot')‬
‭plt.legend()‬
‭plt.show()‬

#‭ Bar chart example‬


‭categories = ['Uttar Pradesh', 'Maharashtra', 'Bihar', 'West Bengal', 'Madhya Pradesh']‬
‭LAB MANUAL [IV --- Python Lab] Page‬‭26‬
‭Mahatma Gandhi Mission's College of Engineering and Technology‬

‭Department of Computer Science and Engineering (AIML &DS)‬

‭Academic Year 2024-25(Even Sem)‬

v‭ alues = [199.8, 123.1, 124.8, 99.6, 85.3]‬


‭plt.figure(figsize=(6, 5))‬
‭plt.bar(categories, values, color='green')‬
‭plt.title('Bar Chart: Indian States vs Population (in millions)')‬
‭plt.xlabel('States of India')‬
‭plt.ylabel('Population (in millions)')‬
‭plt.show()‬

#‭ Histogram example‬
‭data = np.random.randn(1000)‬
‭plt.figure(figsize=(6, 5))‬
‭plt.hist(data, bins=30, color='lightblue', edgecolor='black')‬
‭plt.title('Histogram: Distribution of Random Data')‬
‭plt.xlabel('Value')‬
‭plt.ylabel('Frequency')‬
‭plt.grid(True)‬
‭plt.show()‬

#‭ Pie chart example‬


‭labels = ['Python', 'Java', 'C++', 'JavaScript', 'Ruby']‬
‭sizes = [40, 25, 15, 10, 10]‬
‭colors = ['lightcoral', 'lightskyblue', 'lightgreen', 'lightgoldenrodyellow', 'lavender']‬
‭plt.figure(figsize=(5, 5))‬
‭plt.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=140, colors=colors)‬
‭plt.title('Programming Language Usage in Software Project', pad=20)‬
‭plt.axis('equal')‬
‭plt.tight_layout()‬
‭plt.show()‬

‭OUTPUT:‬

‭LAB MANUAL [IV --- Python Lab] Page‬‭27‬


‭Mahatma Gandhi Mission's College of Engineering and Technology‬

‭Department of Computer Science and Engineering (AIML &DS)‬

‭Academic Year 2024-25(Even Sem)‬

‭Conclusion: In this way we implemented python programs to understand Data visualization‬


‭LAB MANUAL [IV --- Python Lab] Page‬‭28‬

You might also like