0% found this document useful (0 votes)
5 views6 pages

Benefits of Matplotlib for Data Visualization

Matplotlib is a versatile plotting library that supports various graph types and integrates well with libraries like NumPy and Pandas. It allows for interactive features and multiple export formats, making it suitable for diverse data visualization needs. The document also discusses multithreading in Python, detailing its advantages, thread creation methods, and the life cycle of threads.

Uploaded by

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

Benefits of Matplotlib for Data Visualization

Matplotlib is a versatile plotting library that supports various graph types and integrates well with libraries like NumPy and Pandas. It allows for interactive features and multiple export formats, making it suitable for diverse data visualization needs. The document also discusses multithreading in Python, detailing its advantages, thread creation methods, and the life cycle of threads.

Uploaded by

rutikhonde274
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Advantage of using Matplotlib

===================================================================================
==
1. it supports various types of plots or graphs
a. line
b. bar
c. scatter
d. pie
e. histogram
f. box
g. 3D plots
2. it is integrated with other libraries like numpy and pandas
3. it support various export formats .png,.pdf,...
4. interactive features (zoom,...)
===============================================================================
plot Type function Use Cases
===================================================================================
1. Line Plot [Link]() Time Series,Trends
2. Bar Plot [Link]() Comparisions between categories
3. Scatter Plot [Link]() Correlations between variables
4. Histogram [Link]() Frequence Distribution
5. Box Plot [Link]() Outliers
6. subplots [Link]() Multiple plots in plot or figure
===================================================================================
==
Basic steps for plotting
==========================================================================
1. import library

import [Link] as <alias-name>

matplotlib is a package
pyplot is a module
2. Prepare Data for plotting
3. Draw Plot
===================================================================================
=
import [Link] as plt

days=['MON','TUE','WED','THU','FRI']
sales=[200,220,250,270,300]
[Link](days,sales,color="green",marker="o",linestyle="-")
[Link]("Daily Sales Trend")
[Link]("Days of the week")
[Link]("Sales")
[Link](True)
[Link]()
=========================================================================
#Bar Chart
import [Link] as plt

products=["A","B","C","D"]
revenue=[5000,7000,4000,9000]

[Link](products,revenue,color=['blue','green','orange','red'])
[Link]("Product Wise Revenue")
[Link]("Product")
[Link]("Revenue in Cr")
[Link](True)
[Link]()
================================================================================
[Link](products,revenue,color=['blue','green','orange','red'])
[Link]("Product Wise Revenue")
[Link]("Product")
[Link]("Revenue in Cr")
[Link](True)
[Link]()
=========================================================================
# Scatter plot
# Identify relationship between age and spending score
# in marketing dataset

import numpy as np
import [Link] as plt

x=[Link](1,100,50)
y=[Link](1,100,50)

[Link](x,y,color='red')
[Link]("Age")
[Link]("Spending Score")
[Link](True)
[Link]()

===================================================================================
=
# Pie Chart
import [Link] as plt

size=[40,30,20,10]
labels=['Electronics','Fashion','Grocery','Other']
color=['gold','lightblue','lightgreen','pink']
[Link](size,labels=labels,colors=color,startangle=140)
[Link]("Market Share by Categories")
[Link]()
===================================================================================
=
# Histogram
import [Link] as plt

data=[22,87,5,43,56,73,55,54,11,20,51,5,79,31,27]
[Link](data,color="skyblue",edgecolor="black",bins=8)
[Link]("Marks Distributions")
[Link]("Marks Range")
[Link]("Number of Stuudents")
[Link]()

==================================================================================
# Dynamic Update
import [Link] as plt
import numpy as np

[Link]()
x=[]
y=[]

for i in range(20):
[Link](i)
[Link]([Link](i))
[Link]()
[Link](x,y,color="green",marker="o")
[Link]("dynamic update")
[Link]("Time")
[Link]("Amplitude")
[Link](0.5)

[Link]()
[Link]()
===================================================================================
# Data Visualization Using pandas

import [Link] as plt


import pandas as pd
data={'year':[2019,2020,2021,2022,2023],
'Revenue':[400,450,500,550,600]}

df=[Link](data)
[Link](x="year",y="Revenue",kind="bar",legend=True)
[Link]("Company Revenue")
[Link]("Revenue")
[Link]("[Link]")
[Link]()
===================================================================================
=
Multithreading
==============================================================================
Types of applications
======================
1. Single Tasking Applications
2. Multitasking Applications

A Task is nothing but an operation performed by application is called task


An appliction which allows to perform only task is called single tasking
application
An application which allows to execute more than one task or operation
simulteneously or concurrently is called multitasking application

What is thread?
thread is an independent part of execution of within program or process
simulteneous execution of more than one thread is called multithreading or thread
based multitasking

for developing thread based applications python provides a standard module


"threading".

(OR) threading module is used for developing threads and thread based applications
===================================================================================
Advantage of multitasking
===================================================================================
=
utilization of CPU idle time
Resource sharing
===================================================================================
==
thread can be developed in 2 ways
===================================================================================
==
1. function based threads
2. class based threads
===================================================================================
=
Thread class or datatype
===================================================================================
=
Thread class or data type represents activity or operation performed by thread.

Creating function based thread


===============================
1. develop function/task executed by thread
2. create thread class or thread object by giving developed function as a target
3. start thread by invoked start method

Example:
========
import time
import threading
def even_num():
for num in range(1,21):
if num%2==0:
print(f'Even {num}')

def odd_num():
for num in range(1,21):
if num%2!=0:
print(f'Odd {num}')

t1=[Link](target=even_num)
t2=[Link](target=odd_num)

[Link]()
[Link]()
===================================================================================
==
class based thread
===================================================================================
==
1. develop a class by inheriting Thread class
2. inside this class provide functionality by defining run() method
3. create object of developed class
4. execute thread by invoking start() method
===================================================================================
==
import threading

class EvenThread([Link]):
def run(self):
for num in range(1,21):
if num%2==0:
print(f'Even {num}')

class OddThread([Link]):
def run(self):
for num in range(1,21):
if num%2!=0:
print(f'Odd {num}')

t1=EvenThread()
t2=OddThread()
[Link]()
[Link]()
===================================================================================
==
thread scheduling is done by thread shchedular provided by operating system (PVM)
time slicing/preemptive scheduling
life cycle of thread
1. new born state
2. runnable state/ready state
3. running state
4. idle state
5. dead state
===================================================================================
=
import time
import threading
def even_num(m,n):
for num in range(m,n):
if num%2==0:
print(f'Even {num}')

def odd_num(m,n):
for num in range(m,n):
if num%2!=0:
print(f'Odd {num}')

t1=[Link](target=even_num,args=(1,21))
t2=[Link](target=odd_num,args=(1,21))

[Link]()
[Link]()
===================================================================================
=
Thread Synchronization
===================================================================================

Race Condition

You might also like