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

10-numpy-matplotlib

The document provides an overview of Python libraries Numpy and Matplotlib, highlighting their functionalities for high-performance computing and data visualization. Numpy is efficient for numerical computations and array manipulations, while Matplotlib is used for creating various types of plots and visualizations. Key features of both libraries, such as ndarray creation, arithmetic operations, and plotting capabilities, are discussed along with references for further learning.

Uploaded by

saramukhopadhyay
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)
3 views

10-numpy-matplotlib

The document provides an overview of Python libraries Numpy and Matplotlib, highlighting their functionalities for high-performance computing and data visualization. Numpy is efficient for numerical computations and array manipulations, while Matplotlib is used for creating various types of plots and visualizations. Key features of both libraries, such as ndarray creation, arithmetic operations, and plotting capabilities, are discussed along with references for further learning.

Uploaded by

saramukhopadhyay
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
You are on page 1/ 10

Python Libraries:

numpy and
matplotlib
Kameswari Chebrolu
Numpy (Numeric Python)
• Library used for high performance computing and data
analysis
– High-level math functions involving arrays/matrices
– Fast numerical computations like matrix multiplication; linear
algebra/fourier transform etc
• Very efficient for large arrays of data
– Stores data contiguously → less memory, faster operation
(10-100 times faster)
• 1000 x 1000 matrix multiply
– Python triple loop takes > 10 min.
– Numpy takes ~0.03 seconds
– Batch operations can be managed without writing loops
(vectorization)
Ndarray (n-dimentional-array)
• ndarray used for storage of homogeneous data
– All elements the same type
• Supports convenient slicing, indexing and efficient vectorized
computation
• Every array must have a shape and a dtype (data type)
– Vector: array in single dimension
– Matrix: array in two dimensions
– Tensor: 3-D or higher dimensional arrays
• Create arrays (see arrays.py)
– Different data types, dimensions
– Conversion from one type to another
– Copy vs view
• Create special arrays (see special-arrays.py)
– eye, zeros, ones, random, in a range
• Indexing of arrays
– Slicing, stepping, accessing columns/rows
– Printing rows, elements
• Shaping of arrays
– Convert 1D to 2D/3D, 2D to 3D, 3D to 1D etc
• Arithmetic
– Element by element arithmetic for same shaped
arrays
– Broadcasting in case of dissimilar shapes (see
next slide)
– Dot multiplication, transpose
– Trignometric functions
– Stat functions
Broadcasting
• Functions:
– concatenate
– stack
– split, array_split
– where
– sort
• Filtering
Matplotlib
• Used for drawing charts and for general
visualization
– Inspired by MATLAB (lot of common terms like axis,
plots etc)
• Most of the Matplotlib utilities lies under the
pyplot submodule
– You can import it via the matplotlib.pyplot namespace
– Each pyplot function makes some change to a figure
• E.g. create a plotting area, draw some lines, decorates the
plot with labels etc
• Plot (specify marker, line characteristics)
• Multiple plots
• Labels, Title, Grid
• Subplots
• Different plots
– Scatter, Bar, Pie
• Use of math functions
• Saving figures to a file
References
• Numpy:
https://www.w3schools.com/python/numpy/
default.asp
• Matplotlib:
https://www.w3schools.com/python/matplot
lib_pyplot.asp

You might also like