This Edureka Python Matplotlib tutorial (Python Tutorial Blog: https://goo.gl/wd28Zr) explains what is data visualization and how to perform data visualization using Matplotlib. It also explains how to modify your plot and how to plot various types of graphs. Below are the topics covered in this tutorial:
1. Why Data Visualization?
2. What Is Data Visualization?
3. Various Types Of Plots
4. What Is Matplotlib?
6. How To Use Matplotlib?
This slide is used to do an introduction for the matplotlib library and this will be a very basic introduction. As matplotlib is a very used and famous library for machine learning this will be very helpful to teach a student with no coding background and they can start the plotting of maps from the ending of the slide by there own.
The slides I was using when delivering a meetup about the matplotlib library. More info about that meetup can be found at https://www.meetup.com/life-michael/events/271738271/
This Edureka Python Matplotlib tutorial (Python Tutorial Blog: https://goo.gl/wd28Zr) explains what is data visualization and how to perform data visualization using Matplotlib. It also explains how to modify your plot and how to plot various types of graphs. Below are the topics covered in this tutorial:
1. Why Data Visualization?
2. What Is Data Visualization?
3. Various Types Of Plots
4. What Is Matplotlib?
6. How To Use Matplotlib?
This slide is used to do an introduction for the matplotlib library and this will be a very basic introduction. As matplotlib is a very used and famous library for machine learning this will be very helpful to teach a student with no coding background and they can start the plotting of maps from the ending of the slide by there own.
The slides I was using when delivering a meetup about the matplotlib library. More info about that meetup can be found at https://www.meetup.com/life-michael/events/271738271/
This is the basic introduction of the pandas library, you can use it for teaching this library for machine learning introduction. This slide will be able to help to understand the basics of pandas to the students with no coding background.
Abstract: This PDSG workshop introduces the basics of Python libraries used in machine learning. Libraries covered are Numpy, Pandas and MathlibPlot.
Level: Fundamental
Requirements: One should have some knowledge of programming and some statistics.
Looking for a computer institute to learn Full Stack development and Digital Marketing? Our institute offers comprehensive courses in both areas, providing students with the skills and knowledge needed to succeed in today's digital landscape
Regular expressions are used to identify whether a pattern exists in a given sequence of characters (string) or not. They help in manipulating textual data, which is often a pre-requisite for data science projects that involve text mining. You must have come across some application of regular expressions: they are used at the server side to validate the format of email addresses or password during registration, used for parsing text data files to find, replace or delete certain string, etc.
( Python Training: https://www.edureka.co/python )
This Edureka Python Numpy tutorial (Python Tutorial Blog: https://goo.gl/wd28Zr) explains what exactly is Numpy and how it is better than Lists. It also explains various Numpy operations with examples.
Check out our Python Training Playlist: https://goo.gl/Na1p9G
This tutorial helps you to learn the following topics:
1. What is Numpy?
2. Numpy v/s Lists
3. Numpy Operations
4. Numpy Special Functions
YouTube Link: https://youtu.be/mHezNgNBnuA
** Python Certification Training: https://www.edureka.co/python **
This Edureka PPT on 'Date and Time in Python' will train you to use the datetime and time modules to fetch, set and modify date and time in python.
Below are the topics covered in this PPT:
The time module
Built-in functions
Examples
The datetime module
Built-in functions
Examples
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
This presentation is all about various built in
datastructures which we have in python.
List
Dictionary
Tuple
Set
and various methods present in each data structure
PYTHON-Chapter 4-Plotting and Data Science PyLab - MAULIK BORSANIYAMaulik Borsaniya
Advanced Topics I: Plotting and Data Science
Plotting using PyLab, Plotting mortgages and extended examples
Data Science Using Python: Data Frame (Creating Data Frame from an Excel Spreadsheet, Creating Data Frame from .csv Files, Creating Data Frame from a Python Dictionary, Creating Data from Python List of Tuples, Operations on Data Frames),
Data Visualization : Bar Graph, Histogram, Creating a Pie Chart, Creating Line Graph
This is the basic introduction of the pandas library, you can use it for teaching this library for machine learning introduction. This slide will be able to help to understand the basics of pandas to the students with no coding background.
Abstract: This PDSG workshop introduces the basics of Python libraries used in machine learning. Libraries covered are Numpy, Pandas and MathlibPlot.
Level: Fundamental
Requirements: One should have some knowledge of programming and some statistics.
Looking for a computer institute to learn Full Stack development and Digital Marketing? Our institute offers comprehensive courses in both areas, providing students with the skills and knowledge needed to succeed in today's digital landscape
Regular expressions are used to identify whether a pattern exists in a given sequence of characters (string) or not. They help in manipulating textual data, which is often a pre-requisite for data science projects that involve text mining. You must have come across some application of regular expressions: they are used at the server side to validate the format of email addresses or password during registration, used for parsing text data files to find, replace or delete certain string, etc.
( Python Training: https://www.edureka.co/python )
This Edureka Python Numpy tutorial (Python Tutorial Blog: https://goo.gl/wd28Zr) explains what exactly is Numpy and how it is better than Lists. It also explains various Numpy operations with examples.
Check out our Python Training Playlist: https://goo.gl/Na1p9G
This tutorial helps you to learn the following topics:
1. What is Numpy?
2. Numpy v/s Lists
3. Numpy Operations
4. Numpy Special Functions
YouTube Link: https://youtu.be/mHezNgNBnuA
** Python Certification Training: https://www.edureka.co/python **
This Edureka PPT on 'Date and Time in Python' will train you to use the datetime and time modules to fetch, set and modify date and time in python.
Below are the topics covered in this PPT:
The time module
Built-in functions
Examples
The datetime module
Built-in functions
Examples
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
This presentation is all about various built in
datastructures which we have in python.
List
Dictionary
Tuple
Set
and various methods present in each data structure
PYTHON-Chapter 4-Plotting and Data Science PyLab - MAULIK BORSANIYAMaulik Borsaniya
Advanced Topics I: Plotting and Data Science
Plotting using PyLab, Plotting mortgages and extended examples
Data Science Using Python: Data Frame (Creating Data Frame from an Excel Spreadsheet, Creating Data Frame from .csv Files, Creating Data Frame from a Python Dictionary, Creating Data from Python List of Tuples, Operations on Data Frames),
Data Visualization : Bar Graph, Histogram, Creating a Pie Chart, Creating Line Graph
This project is based on Library Management. Python and MySQL are the programming platforms which are used in making of this project.
Subject-Informatics Practices
Class-11/12
A talk from Toronto's FITC Spotlight on Hardware talk. I spoke about using tools like Openframeworks, OpenCV, and the Kinect to create Interactive Installations, and paired it with an interactive lighting installation.
References, citations, and source code can be found here: http://www.andrewlb.com/2013/06/sls-notes/
Best Data Science Ppt using Python
Data science is an inter-disciplinary field that uses scientific methods, processes, algorithms and systems to extract knowledge and insights from many structural and unstructured data. Data science is related to data mining, machine learning and big data.
This tutor shows the train and test set split with binary classifying, clustering and 3D plots and discuss a probability density function in scikit-learn on synthetic datasets. The dataset is very simple as a reference of understanding.
bisection method of ppt
bisection method of ppt
bisection method of ppt
bisection method of ppt
bisection method of ppt
bisection method of ppt
bisection method of ppt
bisection method of ppt
Numbers, math operation, converting basesAmir Shokri
numbers :
- Base number 10
- Base number 2
- Base number 8
- Base number 16
converting bases :
- Convert base 10 to base 2, to base 8, to base 16
- Convert base 8 to base 2, to base 10, to base 16
- Convert base 16 to base 2, to base 8, to base 10
- Convert base 2 to base 10, to base 8, to base 16
Mathematical operations: addition, subtraction, division, multiplication on numerical bases
Popular Maple codes - By Amir Shokri
Email : amirsh.nll@gmail.com
Blog :www.ashokri.com
Updated Time : 09/21/2020
Language : Persian(Farsi)
هرگونه کپی برداری و استفاده ی تجاری از این فایل غیر مجاز می باشد و این فایل به صورت کاملا رایگان منتشر شده است؛ در صورتی که این نسخه به صورت غیر رایگان در جایی ارائه شده است از طریق ایمیل به من اطلاع دهید.
Software Engineering, Software Consulting, Tech Lead.
Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Security,
Spring Transaction, Spring MVC,
Log4j, REST/SOAP WEB-SERVICES.
Advanced Flow Concepts Every Developer Should KnowPeter Caitens
Tim Combridge from Sensible Giraffe and Salesforce Ben presents some important tips that all developers should know when dealing with Flows in Salesforce.
Modern design is crucial in today's digital environment, and this is especially true for SharePoint intranets. The design of these digital hubs is critical to user engagement and productivity enhancement. They are the cornerstone of internal collaboration and interaction within enterprises.
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...informapgpstrackings
Keep tabs on your field staff effortlessly with Informap Technology Centre LLC. Real-time tracking, task assignment, and smart features for efficient management. Request a live demo today!
For more details, visit us : https://informapuae.com/field-staff-tracking/
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Unleash Unlimited Potential with One-Time Purchase
BoxLang is more than just a language; it's a community. By choosing a Visionary License, you're not just investing in your success, you're actively contributing to the ongoing development and support of BoxLang.
Listen to the keynote address and hear about the latest developments from Rachana Ananthakrishnan and Ian Foster who review the updates to the Globus Platform and Service, and the relevance of Globus to the scientific community as an automation platform to accelerate scientific discovery.
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
Even though at surface level ‘java.lang.OutOfMemoryError’ appears as one single error; underlyingly there are 9 types of OutOfMemoryError. Each type of OutOfMemoryError has different causes, diagnosis approaches and solutions. This session equips you with the knowledge, tools, and techniques needed to troubleshoot and conquer OutOfMemoryError in all its forms, ensuring smoother, more efficient Java applications.
Cyaniclab : Software Development Agency Portfolio.pdfCyanic lab
CyanicLab, an offshore custom software development company based in Sweden,India, Finland, is your go-to partner for startup development and innovative web design solutions. Our expert team specializes in crafting cutting-edge software tailored to meet the unique needs of startups and established enterprises alike. From conceptualization to execution, we offer comprehensive services including web and mobile app development, UI/UX design, and ongoing software maintenance. Ready to elevate your business? Contact CyanicLab today and let us propel your vision to success with our top-notch IT solutions.
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
Large Language Models (LLMs) are currently the center of attention in the tech world, particularly for their potential to advance research. In this presentation, we'll explore a straightforward and effective method for quickly initiating inference runs on supercomputers using the vLLM tool with Globus Compute, specifically on the Polaris system at ALCF. We'll begin by briefly discussing the popularity and applications of LLMs in various fields. Following this, we will introduce the vLLM tool, and explain how it integrates with Globus Compute to efficiently manage LLM operations on Polaris. Attendees will learn the practical aspects of setting up and remotely triggering LLMs from local machines, focusing on ease of use and efficiency. This talk is ideal for researchers and practitioners looking to leverage the power of LLMs in their work, offering a clear guide to harnessing supercomputing resources for quick and effective LLM inference.
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
The Earth System Grid Federation (ESGF) is a global network of data servers that archives and distributes the planet’s largest collection of Earth system model output for thousands of climate and environmental scientists worldwide. Many of these petabyte-scale data archives are located in proximity to large high-performance computing (HPC) or cloud computing resources, but the primary workflow for data users consists of transferring data, and applying computations on a different system. As a part of the ESGF 2.0 US project (funded by the United States Department of Energy Office of Science), we developed pre-defined data workflows, which can be run on-demand, capable of applying many data reduction and data analysis to the large ESGF data archives, transferring only the resultant analysis (ex. visualizations, smaller data files). In this talk, we will showcase a few of these workflows, highlighting how Globus Flows can be used for petabyte-scale climate analysis.
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
Unlocking Business Potential: Tailored Technology Solutions by Prosigns
Discover how Prosigns, a leading technology solutions provider, partners with businesses to drive innovation and success. Our presentation showcases our comprehensive range of services, including custom software development, web and mobile app development, AI & ML solutions, blockchain integration, DevOps services, and Microsoft Dynamics 365 support.
Custom Software Development: Prosigns specializes in creating bespoke software solutions that cater to your unique business needs. Our team of experts works closely with you to understand your requirements and deliver tailor-made software that enhances efficiency and drives growth.
Web and Mobile App Development: From responsive websites to intuitive mobile applications, Prosigns develops cutting-edge solutions that engage users and deliver seamless experiences across devices.
AI & ML Solutions: Harnessing the power of Artificial Intelligence and Machine Learning, Prosigns provides smart solutions that automate processes, provide valuable insights, and drive informed decision-making.
Blockchain Integration: Prosigns offers comprehensive blockchain solutions, including development, integration, and consulting services, enabling businesses to leverage blockchain technology for enhanced security, transparency, and efficiency.
DevOps Services: Prosigns' DevOps services streamline development and operations processes, ensuring faster and more reliable software delivery through automation and continuous integration.
Microsoft Dynamics 365 Support: Prosigns provides comprehensive support and maintenance services for Microsoft Dynamics 365, ensuring your system is always up-to-date, secure, and running smoothly.
Learn how our collaborative approach and dedication to excellence help businesses achieve their goals and stay ahead in today's digital landscape. From concept to deployment, Prosigns is your trusted partner for transforming ideas into reality and unlocking the full potential of your business.
Join us on a journey of innovation and growth. Let's partner for success with Prosigns.
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
Recreation management software streamlines operations by automating key tasks such as scheduling, registration, and payment processing, reducing manual workload and errors. It provides centralized management of facilities, classes, and events, ensuring efficient resource allocation and facility usage. The software offers user-friendly online portals for easy access to bookings and program information, enhancing customer experience. Real-time reporting and data analytics deliver insights into attendance and preferences, aiding in strategic decision-making. Additionally, effective communication tools keep participants and staff informed with timely updates. Overall, recreation management software enhances efficiency, improves service delivery, and boosts customer satisfaction.
How Recreation Management Software Can Streamline Your Operations.pptx
Matplotlib
1. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 1/43
Matplotlib
Assistant Professor :
Dr. Fadaeieslam
By :
Amir Shokri
Farshad Asgharzade
Alireza Gholamnia
Introduction:
Matplotlib is one of the most popular Python packages used for
data visualization. Matplotlib was originally written by John D.
Hunter in 2003. Pyplot is a Matplotlib module which provides a
MATLAB-like interface. Matplotlib is designed to be as usable as
MATLAB, with the ability to use Python, and the advantage of
being free and open-source. Matplotlib is open source and we
can use it freely. The purpose of a plotting package is to assist
2. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 2/43
you in visualizing your data as easily as possible, with all the
necessary control that is, by using relatively high-level commands
most of the time, and still have the ability to use the low-level
commands when needed.
Installation of Matplotlib:
If you have Python and PIP already installed on a system, then
installation of Matplotlib is very easy. Install it using this
command:
pip install matplotlib
Matplotlib requires the following dependencies:
NumPy
setuptools
cycler
dateutil
kiwisolver
Pillow
pyparsing
Anaconda distribution:
Anaconda is a free and open source distribution of the Python and
R programming languages for large-scale data processing,
predictive analytics, and scientific computing. The distribution
makes package management and deployment simple and easy.
Matplotlib and lots of other useful (data) science tools form part of
the distribution. Package versions are managed by the package
management system Conda. The advantage of Anaconda is that
you have access to over 720 packages that can easily be installed
with Anaconda's Conda, a package, dependency, and
environment manager.
3. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 3/43
Checking Matplotlib Version:
Once Matplotlib is installed, import it in your applications by
adding the import module statement:
In [1]:
Most of the Matplotlib utilities lies under the pyplot submodule,
and are usually imported under the plt alias:
In [2]:
matplotlib.pyplot is a collection of functions that make matplotlib
work like MATLAB. Each pyplot function makes some change to a
figure: e.g., creates a figure, creates a plotting area in a figure,
plots some lines in a plotting area, decorates the plot with labels,
etc.
Generating visualizations with pyplot
is very quick:
Out[1]: '3.3.2'
import matplotlib
matplotlib.__version__
import matplotlib.pyplot as plt
4. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 4/43
In [3]:
In [4]:
You may be wondering why the x-axis ranges from 0-3 and the y-
axis from 1-4. If you provide a single list or array to plot, matplotlib
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4],[1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()
5. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 5/43
assumes it is a sequence of y values, and automatically generates
the x values for you. Since python ranges start with 0, the default
x vector has the same length as y but starts with 0. Hence the x
data are [0, 1, 2, 3].
Formatting the style of your plot:
For every x, y pair of arguments, there is an optional third
argument which is the format string that indicates the color and
line type of the plot. The letters and symbols of the format string
are from MATLAB, and you concatenate a color string with a line
style string. The default format string is 'b-', which is a solid blue
line. For example, to plot the above with red circles, you would
issue
In [5]: plt.plot([1, 2, 3, 4], [1, 4, 9, 16], 'ro')
plt.axis([0, 6, 0, 20])
plt.show()
6. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 6/43
In [6]:
In [7]:
plt.plot([1, 2, 3, 4], [1, 4, 9, 16], 'r+') # ditto, but with red pluss
plt.axis([0, 6, 0, 20])
plt.show()
plt.plot([1, 2, 3, 4], [1, 4, 9, 16],'go--', linewidth=2, markersize=12)
plt.axis([0, 6, 0, 20])
plt.show()
7. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 7/43
In [8]:
Marker Size : You can use the keyword argument markersize or
the shorter version, ms to set the size of the markers
In [9]:
Marker Color: You can use the keyword argument markerfacecolor
or the shorter mfc to set the color inside the edge of the markers:
ypoints = [3, 8, 1, 10]
plt.plot(ypoints, 'o:r')
plt.show()
ypoints = [3, 8, 1, 10]
plt.plot(ypoints, marker = 'o', ms = 20)
plt.show()
8. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 8/43
In [10]:
For more visit
https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html#matplotlib.pyplot.plot
(https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html#matplotlib.pyplot.plot)
Use with numpy
If matplotlib were limited to working with lists, it would be fairly
useless for numeric processing. Generally, you will use numpy
arrays. In fact, all sequences are converted to numpy arrays
internally. The example below illustrates plotting several lines with
different format styles in one function call using arrays.
ypoints =[3, 8, 1, 10]
plt.plot(ypoints, marker = 'o', ms = 20, mec = 'r', mfc = 'r')
plt.show()
9. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 9/43
In [11]:
Display Multiple Plots
the subplots() function takes three arguments that describes the
layout of the figure. The layout is organized in rows and columns,
which are represented by the first and second argument. The third
argument represents the index of the current plot.
import numpy as np
import matplotlib.pyplot as plt
# evenly sampled time at 200ms intervals
t = np.arange(0., 5., 0.2)
# red dashes, blue squares and green triangles
plt.plot(t, t, 'r--', t, t*2, 'bs', t, t*3, 'g^')
plt.show()
10. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 10/43
In [12]: x = np.array([0, 1, 2, 3])
y = np.array([3, 8, 1, 10])
plt.subplot(2, 1, 1)
plt.plot(x,y)
x = np.array([0, 1, 2, 3])
y = np.array([10, 20, 30, 40])
plt.subplot(2, 1, 2)
plt.plot(x,y)
plt.show()
11. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 11/43
In [13]: x = np.array([0, 1, 2, 3])
y = np.array([3, 8, 1, 10])
plt.subplot(2, 3, 1)
plt.plot(x,y)
x = np.array([0, 1, 2, 3])
y = np.array([10, 20, 30, 40])
plt.subplot(2, 3, 2)
plt.plot(x,y)
x = np.array([0, 1, 2, 3])
y = np.array([3, 8, 1, 10])
plt.subplot(2, 3, 3)
plt.plot(x,y)
x = np.array([0, 1, 2, 3])
y = np.array([10, 20, 30, 40])
plt.subplot(2, 3, 4)
plt.plot(x,y)
x = np.array([0, 1, 2, 3])
y = np.array([3, 8, 1, 10])
plt.subplot(2, 3, 5)
plt.plot(x,y)
x = np.array([0, 1, 2, 3])
y = np.array([10, 20, 30, 40])
plt.subplot(2, 3, 6)
plt.plot(x,y)
plt.show()
12. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 12/43
In [14]:
Subplot2grid() Function
This function gives more flexibility in creating an axes object at a
specific location of the grid. It also allows the axes object to be
spanned across multiple rows or columns.
Plt.subplot2grid(shape, location, rowspan,
colspan)
x = np.array([0, 1, 2, 3])
y = np.array([3, 8, 1, 10])
plt.subplot(1, 2, 1)
plt.plot(x,y)
plt.title("SALES")
x = np.array([0, 1, 2, 3])
y = np.array([10, 20, 30, 40])
plt.subplot(1, 2, 2)
plt.plot(x,y)
plt.title("INCOME")
plt.suptitle("MY SHOP")
plt.show()
13. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 13/43
In [15]:
Grids
The grid() function of axes object sets visibility of grid inside the
figure to on or off. You can also display major / minor (or both)
ticks of the grid. Additionally color, linestyle and linewidth
properties can be set in the grid() function.
a1 = plt.subplot2grid((3,3),(0,0),colspan = 2)
a2 = plt.subplot2grid((3,3),(0,2), rowspan = 3)
a3 = plt.subplot2grid((3,3),(1,0),rowspan = 2, colspan = 2)
x = np.arange(1,10)
a2.plot(x, x*x)
a2.set_title('square')
a1.plot(x, np.exp(x))
a1.set_title('exp')
a3.plot(x, np.log(x))
a3.set_title('log')
plt.tight_layout()
plt.show()
14. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 14/43
In [16]:
Working with text
text can be used to add text in an arbitrary location, and xlabel,
ylabel and title are used to add text in the indicated locations (see
Text in Matplotlib Plots for a more detailed example)
Using mathematical expressions in text:
plt.text(60, .025, r'$mu=100, sigma=15$')
matplotlib accepts laTeX equation expressions in any text
expression.
import matplotlib.pyplot as plt
import numpy as np
fig, axes = plt.subplots(1,3, figsize = (12,4))
x = np.arange(1,11)
axes[0].plot(x, x**3, 'g',lw=2)
axes[0].grid(True)
axes[0].set_title('default grid')
axes[1].plot(x, np.exp(x), 'r')
axes[1].grid(color='b', ls = '-.', lw = 0.25)
axes[1].set_title('custom grid')
axes[2].plot(x,x)
axes[2].set_title('no grid')
fig.tight_layout()
plt.show()
15. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 15/43
In [17]:
Annotating text
The uses of the basic text function above place text at an arbitrary
position on the Axes. A common use for text is to annotate some
feature of the plot, and the annotate method provides helper
functionality to make annotations easy. In an annotation, there are
two points to consider: the location being annotated represented
by the argument xy and the location of the text xytext. Both of
these arguments are (x, y) tuples.
mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)
# the histogram of the data
n, bins, patches = plt.hist(x, 50, density=1, facecolor='g', alpha=0.75)
plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title('Histogram of IQ')
plt.text(60, .025, r'$mu=100, sigma=15$')
plt.axis([40, 160, 0, 0.03])
plt.grid(True)
plt.show()
16. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 16/43
In [18]:
Logarithmic and other nonlinear
axes
matplotlib.pyplot supports not only linear axis scales, but also
logarithmic and logit scales. This is commonly used if data spans
many orders of magnitude. Changing the scale of an axis is easy:
plt.xscale('log')
ax = plt.subplot(111)
t = np.arange(0.0, 5.0, 0.01)
s = np.cos(2*np.pi*t)
line, = plt.plot(t, s, lw=2)
plt.annotate('local max', xy=(2, 1), xytext=(3, 1.5),
arrowprops=dict(facecolor='black', shrink=0.05),
)
plt.ylim(-2, 2)
plt.show()
17. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 17/43
In [19]:
from matplotlib.pyplot import figure
# make up some data in the open interval (0, 1)
y = np.random.normal(loc=0.5, scale=0.4, size=1000)
y = y[(y > 0) & (y < 1)]
y.sort()
x = np.arange(len(y))
figure(num=None, figsize=(10, 10))
# linear
plt.plot(x, y)
plt.yscale('linear')
plt.title('linear')
plt.grid(True)
22. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 22/43
With Pyplot, you can use the bar() function to draw bar graphs
The bar() function takes arguments that describes the layout of the
bars. The categories and their values represented by the first and
second argument as arrays.
x = ["APPLES", "BANANAS"]
y = [400, 350]plt.bar(x, y)
plt.bar(x, y)
In [23]:
Matplotlib Pie Charts
A Pie Chart can only display one series of data. Pie charts show
the size of items (called wedge) in one data series, proportional to
the sum of the items. The data points in a pie chart are shown as
a percentage of the whole pie. Explode: Maybe you want one of
the wedges to stand out? The explode parameter allows you to
do that. The explode parameter, if specified, and not None, must
be an array with one value for each wedge.
x = np.array(["A", "B", "C", "D"])
y = np.array([3, 8, 1, 10])
plt.bar(x, y, width = 0.5)
plt.show()
23. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 23/43
In [24]:
Explode: Maybe you want one of the wedges to stand out? The
explode parameter allows you to do that. The explode parameter,
if specified, and not None, must be an array with one value for
each wedge.
fig = plt.figure()
ax = fig.add_axes([0,0,1,1])
ax.axis('equal')
langs = ['C', 'C++', 'Java', 'Python', 'PHP']
students = [23,17,35,29,12]
ax.pie(students, labels = langs,autopct='%1.2f%%')
plt.show()
24. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 24/43
In [25]:
3D Surface plot
Surface plot shows a functional relationship between a designated
dependent variable (Y), and two independent variables (X and Z).
The plot is a companion plot to the contour plot. A surface plot is
like a wireframe plot, but each face of the wireframe is a filled
polygon. This can aid perception of the topology of the surface
being visualized. The plot_surface() function x,y and z as
arguments.
y = np.array([35, 25, 25, 15])
mylabels = ["C", "C++", "Python", "Java"]
myexplode = [0.2, 0, 0, 0]
plt.pie(y, explode = myexplode , labels = mylabels)
plt.show()
25. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 25/43
In [26]: from mpl_toolkits import mplot3d
x = np.outer(np.linspace(-2, 2, 30), np.ones(30))
y = x.copy().T
z = np.cos(x ** 2 + y ** 2)
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.plot_surface(x, y, z,cmap='viridis', edgecolor='none')
ax.set_title('Surface plot')
plt.show()
26. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 26/43
In [27]:
from mpl_toolkits.mplot3d import Axes3D
from scipy.stats import multivariate_normal
x, y = np.mgrid[-1.0:1.0:30j, -1.0:1.0:30j]
xy = np.column_stack([x.flat, y.flat])
mu = np.array([0.0, 0.0])
sigma = np.array([.5, .5])
covariance = np.diag(sigma**2)
z = multivariate_normal.pdf(xy, mean=mu, cov=covariance)
z = z.reshape(x.shape)
fig = plt.figure(num=None, figsize=(10, 10))
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(x,y,z)
plt.show()
27. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 27/43
Seaborn
Seaborn is a Python data visualization library based on matplotlib.
It provides a high-level interface for drawing attractive and
informative statistical graphics.
28. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 28/43
In [28]:
Out[28]: <seaborn.axisgrid.PairGrid at 0x7f94b6a11dd0>
import seaborn as sns
df = sns.load_dataset("penguins")
sns.pairplot(df, hue="species")
29. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 29/43
In [29]:
Working with Images
The image module in Matplotlib package provides functionalities
required for loading, rescaling and displaying image. Loading
image data is supported by the Pillow library and Matplotlib relies
on the Pillow library to load image data. The imread() function is
used to read image data in an ndarray object of float32 dtype.
tips = sns.load_dataset("tips")
g = sns.jointplot(x="total_bill", y="tip", data=tips,
kind="reg", truncate=False,
xlim=(0, 60), ylim=(0, 12),
color="m", height=7)
30. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 30/43
In [30]:
In [31]:
Get image size (width, height,
dimension)
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from matplotlib.pyplot import figure
img = mpimg.imread('mpl.png')
figure(num=None, figsize=(10, 10))
imgplot = plt.imshow(img)
plt.imsave("logo.png", img, origin = 'lower')
newimg = mpimg.imread('logo.png')
imgplot = plt.imshow(newimg)
33. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 33/43
Examining a specific data range
Sometimes you want to enhance the contrast in your image, or
expand the contrast in a particular region while sacrificing the
detail in colors that don't vary much, or don't matter. A good tool
to find interesting regions is the histogram. To create a histogram
of our image data, we use the hist() function.
34. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 34/43
In [34]:
figure(num=None, figsize=(15, 10))
plt.subplot(2, 2, 1)
plt.hist(img_lena.ravel(), bins=256, range=(0.0, 1.0),color = 'Black')
plt.title("lena image histogram")
plt.subplot(2, 2, 2)
plt.hist(red_img_lena.ravel(), bins=256, range=(0.0, 1.0), color = 'red')
plt.title("red chanel of lena image histogram")
plt.subplot(2, 2, 3)
plt.hist(green_img_lena.ravel(), bins=256, range=(0.0, 1.0),color = 'Green'
plt.title("green chanel of lena image histogram")
plt.subplot(2, 2, 4)
plt.hist(blue_img_lena.ravel(), bins=256, range=(0.0, 1.0), color = 'Blue')
plt.title("blue chanel of lena image histogram")
plt.suptitle(" images histogram")
plt.show()
35. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 35/43
In color images, we have 3 color channels representing RGB. In
Combined Color Histogram the intensity count is the sum of all
three color channels.
In [35]:
Histogram equalization
Histogram equalization is a method in image processing of
contrast adjustment using the image's histogram.
import matplotlib.pyplot as plt
image = plt.imread('lena.png')
_ = plt.hist(image.ravel(), bins = 256, color = 'orange', )
_ = plt.hist(image[:, :, 0].ravel(), bins = 256, color = 'red', alpha = 0.5
_ = plt.hist(image[:, :, 1].ravel(), bins = 256, color = 'Green', alpha = 0
_ = plt.hist(image[:, :, 2].ravel(), bins = 256, color = 'Blue', alpha = 0.
_ = plt.xlabel('Intensity Value')
_ = plt.ylabel('Count')
_ = plt.legend(['Total', 'Red_Channel', 'Green_Channel', 'Blue_Channel'])
plt.show()
36. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 36/43
In [40]: # Importing Image and ImageOps module from PIL package
from PIL import Image, ImageOps
figure(num=None, figsize=(15, 10))
im1 = Image.open(r"lena.png")
im2 = ImageOps.equalize(im1, mask = None)
plt.axis('off')
plt.imshow(im2)
plt.show()
38. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 38/43
scikit-image
scikit-image is a collection of algorithms for image processing.
In [43]:
NumPy
Sometimes you want to enhance the contrast in your image, or
expand the contrast in a particular region while sacrificing the
detail in colors that don't vary much, or don't matter. A good tool
to find interesting regions is the histogram. To create a histogram
of our image data, we use the hist() function.
Out[43]: <matplotlib.image.AxesImage at 0x7f949f255b50>
from skimage import data,filters
figure(num=None, figsize=(15, 10))
img_coin = data.coins()
edges_coin = filters.sobel(img_coin)
plt.subplot(1, 2, 1)
plt.axis('off')
plt.imshow(img_coin, cmap='gray')
plt.subplot(1, 2, 2)
plt.axis('off')
plt.imshow(edges_coin, cmap='gray')
39. 11/8/2020 matplotlib - Jupyter Notebook
localhost:8888/notebooks/Desktop/erae/matplotlib_mv/matplotlib.ipynb# 39/43
In [44]:
Using SciPy for blurring using a
Gaussian filter:
Out[44]: <matplotlib.image.AxesImage at 0x7f949fbaab50>
figure(num=None, figsize=(15, 10))
image_camera = data.camera()
plt.subplot(1, 2, 1)
plt.axis('off')
plt.imshow(image_camera, cmap='gray')
mask_camera = image_camera < 87
image_camera[mask_camera]=255
plt.subplot(1, 2, 2)
plt.axis('off')
plt.imshow(image_camera, cmap='gray')