Movatterモバイル変換


[0]ホーム

URL:


Packt
Search iconClose icon
Search icon CANCEL
Subscription
0
Cart icon
Your Cart(0 item)
Close icon
You have no products in your basket yet
Save more on your purchases!discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Profile icon
Account
Close icon

Change country

Modal Close icon
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timerSALE ENDS IN
0Days
:
00Hours
:
00Minutes
:
00Seconds
Home> Programming> Geospatial Analysis> Matplotlib 3.0 Cookbook
Matplotlib 3.0 Cookbook
Matplotlib 3.0 Cookbook

Matplotlib 3.0 Cookbook: Over 150 recipes to create highly detailed interactive visualizations using Python

Arrow left icon
Profile Icon PoladiProfile Icon Borkar
Arrow right icon
$9.99$39.99
Full star iconFull star iconFull star iconEmpty star iconEmpty star icon3(5 Ratings)
eBookOct 2018676 pages1st Edition
eBook
$9.99 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon PoladiProfile Icon Borkar
Arrow right icon
$9.99$39.99
Full star iconFull star iconFull star iconEmpty star iconEmpty star icon3(5 Ratings)
eBookOct 2018676 pages1st Edition
eBook
$9.99 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$9.99 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature iconInstant access to your Digital eBook purchase
Product feature icon Download this book inEPUB andPDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature iconDRM FREE - Read whenever, wherever and however you want

Contact Details

Modal Close icon
Payment Processing...
tickCompleted

Billing Address

Table of content iconView table of contentsPreview book icon Preview Book

Matplotlib 3.0 Cookbook

Introduction

Matplotlib is a cross-platform Python library for plotting two-dimensional graphs (also calledplots). It can be used in a variety of user interfaces such as Python scripts, IPython shells, Jupyter Notebooks, web applications, and GUI toolkits. It can be used to develop professional reporting applications, interactive analytical applications,complexdashboard applications or embed into web/GUI applications. It supports saving figures into various hard-copy formats as well. It also has limited support for three-dimensional figures. It also supports many third-party toolkits to extend its functionality.

Please note that all the examples in this book are tested with Matplotlib 3.0 and Jupyter Notebook 5.1.0.

Architecture of Matplotlib

Matplotlib has a three-layer architecture:backend,artist, andscripting, organized logically as a stack. Scripting is an API that developers use to create the graphs. Artist does the actual job of creating the graph internally. Backend is where the graph is displayed.

Backend layer

This is the bottom-most layer where the graphs are displayed on to an output device. This can be any of the user interfaces that Matplotlib supports. There are two types of backends:user interface backends (for use inpygtk,wxpython,tkinter,qt4, ormacosx, and so on, also referred to asinteractive backends) andhard-copy backends to make image files (.png,.svg,.pdf, and.ps, also referred to asnon-interactive backends). We will learn how to configure these backends in laterChapter 9,Developing Interactive Plots andChapter 10,Embedding Plots in a Graphical User Interface.

Artist layer

This is the middle layer of the stack. Matplotlib uses theartist object to draw various elements of the graph. So, every element (see elements of a figure) we see in the graph is an artist. This layer provides anobject-oriented API for plotting graphs with maximum flexibility. This interface is meant for seasoned Python programmers, who can create complex dashboard applications.

Scripting layer

This is the topmost layer of the stack. This layer provides a simple interface for creating graphs. This is meant for use by end users who don't have much programming expertise. This is called apyplot API.

Elements of a figure

The high-level Matplotlib object that contains all the elements of the output graph is called afigure. Multiple graphs can be arranged in different ways to form a figure. Each of the figure's elements is customizable.

Figure

The following diagram is the anatomy of afigure, containing all its elements:

Anatomy of a figure (Source : http://diagramss.us/plotting-a-graph-in-matlab.html)

Axes

axes is a sub-section of the figure, where a graph is plotted.axes has atitle, anx-label and ay-label. Afigure can have many suchaxes, each representing one or more graphs. In the preceding figure, there is only oneaxes, two line graphs in blue and red colors.

Axis

These are number lines representing the scale of the graphs being plotted. Two-dimensional graphs have anx axis and ay axis, and three-dimensional graphs have anx axis, ay axis, and az axis.

Don't get confused between axes and axis. Axis is an element of axes. Grammatically, axes is also the plural for axis, so interpret the meaning of axes depending on the context, whether multiple axis elements are being referred to or an axes object is being referred to.

Label

This is the name given to various elements of the figure, for example,xaxis label,yaxis label, graph label (blue signal/red signal in the preceding figureAnatomy of a figure), and so on.

Legend

When there are multiple graphs in theaxes (as in the preceding figureAnatomy of a figure), each of them has its own label, and all these labels are represented as a legend. In the preceding figure, the legend is placed at the top-right corner of the figure.

Title

It is the name given to each of theaxes. Thefigure also can have its own title, when the figure has multiple axes with their own titles. The preceding figure has only one axes, so there is only one title for the axes as well as the figure.

Ticklabels

Each axis (x,y, orz) will have a range of values that are divided into many equal bins. Bins are chosen at two levels. In the preceding figureAnatomy of a figure, thexaxis scale ranges from 0 to 4, divided into four major bins (0-1, 1-2, 2-3, and 3-4) and each of the major bins is further divided into four minor bins (0-0.25, 0.25-0.5, and 0.5-0.75). Ticks on both sides of major bins are calledmajor ticks and minor bins are calledminor ticks, and the names given to them aremajor ticklabels andminor ticklabels.

Spines

Boundaries of the figure are calledspines. There are four spines for each axes(top, bottom, left, and right).

Grid

For easier readability of the coordinates of various points on the graph, the area of the graph is divided into a grid. Usually, this grid is drawn along major ticks of thex andy axis. In the preceding figure, the grid is shown in dashed lines.

Working in interactive mode

Matplotlib can be used in aninteractive ornon-interactive modes.In the interactive mode, the graph display gets updated after each statement. In the non-interactive mode, the graph does not get displayed until explicitly asked to do so.

Getting ready

You need working installations of Python, NumPy, and Matplotlib packages.

Using the following commands, interactive mode can be set on or off, and also checked for current mode at any point in time:

  • matplotlib.pyplot.ion() to set the interactive modeON
  • matplotlib.pyplot.ioff() to switchOFF the interactive mode
  • matplotlib.is_interactive() to check whether the interactive mode isON (True) orOFF (False)

How to do it...

Let's see how simple it is to work in interactive mode:

  1. Set the screen output as the backend:
%matplotlib inline
  1. Import thematplotlib andpyplot libraries. It is common practice in Python to import libraries with crisp synonyms. Noteplt is the synonym for thematplotlib.pyplot package:
import matplotlib as mpl
import matplotlib.pyplot as plt
  1. Set the interactive mode to ON:
plt.ion()
  1. Check the status of interactive mode:
mpl.is_interactive()
  1. You should get the output asTrue.
  2. Plot a line graph:
plt.plot([1.5, 3.0])

You should see the following graph as the output:

  1. Now add the axis labels and a title to the graph with the help of the following code:
# Add labels and title
plt.title("Interactive Plot") #Prints the title on top of graph
plt.xlabel("X-axis") # Prints X axis label as "X-axis"
plt.ylabel("Y-axis") # Prints Y axis label as "Y-axis"

After executing the preceding three statements, your graph should look as follows:

How it works...

So, this is how the explanation goes:

  • plt.plot([1.5, 3.0]) plots a line graph connecting two points (0, 1.5) and (1.0, 3.0).
  • Theplot command expects two arguments (Python list, NumPyarray or pandasDataFrame) for thex andy axis respectively.
  • If only one argument is passed, it takes it asy axis co-ordinates and forx axis co-ordinates it takes the length of the argument provided.
  • In this example, we are passing only one list of two points, which will be taken asyaxis coordinates.
  • For thex axis, it takes the default values in the range of 0 to 1, since the length of the list[1.5, 3.0] is 2.
  • If we had three coordinates in the list fory, then forx,it would take the range of 0 to 2.
  • You should see the graph like the one shown instep 6.
  • plt.title("Interactive Plot"), prints the title on top of the graph asInteractive Plot.
  • plt.xlabel("X-axis"), prints thex axis label asX-axis.
  • plt.ylabel("Y-axis"), prints they axis label asY-axis.
  • After executing preceding three statements, you should see the graph as shown instep 7.

If you are using Python shell, after executing each of the code statements, you should see the graph getting updated with title first, then thex axis label, and finally they axis label.

If you are using Jupyter Notebook, you can see the output only after all the statements in a given cell are executed, so you have to put each of these three statements in separate cells and execute one after the other, to see the graph getting updated after each code statement.

In older versions of Matplotlibor certain backends (such asmacosx), the graph may not be updated immediately. In such cases, you need to callplt.draw() explicitly at the end, so that the graph gets displayed.

There's more...

You can add one more line graph to the same plot and go on until you complete your interactive session:

  1. Plot a line graph:
plt.plot([1.5, 3.0])
  1. Add labels and title:
plt.title("Interactive Plot")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
  1. Add one more line graph:
plt.plot([3.5, 2.5])

The following graph is the output obtained after executing the code:

Hence, we have now worked in interactive mode.

Working in non-interactive mode

In the interactive mode, we have seen the graph getting built step by step with each instruction. In non-interactive mode, you give all instructions to build the graph and then display the graph with a command explicitly.

How to do it...

Working on non-interactive mode won't be difficult either:

  1. Start the kernel afresh, and import thematplotlibandpyplot libraries:
import matplotlib
import matplotlib.pyplot as plt
  1. Set the interactive mode to OFF:
plt.ioff()
  1. Check the status of interactive mode:
matplotlib.is_interactive()

  1. You should get the outputFalse.
  2. Execute the following code; you will not see the plot on your screen:
# Plot a line graph
plt.plot([1.5, 3.0])

# Plot the title, X and Y axis labels
plt.title("Non Interactive Mode")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
  1. Execute the following statement, and then you will see the plot on your screen:
# Display the graph on the screen
plt.show()

How it works...

Each of the preceding code statements is self-explanatory. The important thing to note is in non-interactive mode, you write complete code for the graph you want to display, and callplt.show() explicitly to display the graph on the screen.

The following is the output obtained:

The latest versions of Jupyter Notebook seem to display the figure without callingplt.show() command explicitly. However, in Python shell or embedded applications,plt.show() orplt.draw() is required to display the figure on the screen.

Reading from external files and plotting

By default, Matplotlib accepts input data as a Python list, NumPy array, or pandas DataFrame. So all external data needs to be read and converted to one of these formats before feeding it to Matplotlib for plotting the graph. From a performance perspective, NumPy format is more efficient, but for default labels, pandas format is convenient.

If the data is a.txt file, you can use NumPy function to read the data and put it in NumPy arrays. If the data is in.csv or.xlsx formats, you can use pandas to read the data. Here we will demonstrate how to read.txt,.csv, and.xlsx formats and then plot the graph.

Getting ready

Import thematplotlib.pyplot,numpy , andpandas packages that are required to read the input files:

  1. Import thepyplot library with theplt synonym:
import matplotlib.pyplot as plt
  1. Import thenumpy library with thenp synonym. Thenumpy library can manage n-dimensional arrays, supporting all mathematical operations on these arrays:
import numpy as np
  1. Import thepandas package withpd as a synonym:
import pandas as pd

How to do it...

We will follow the order of.txt,.csv, and.xlsx files, in three separate sections.

Reading from a .txt file

Here are some steps to follow:

  1. Read the text file into thetxt variable:
txt = np.loadtxt('test.txt', delimiter = ',')
txt

Here is the explanation for the preceding code block:

  • Thetest.txttext file has 10 numbers separated by a comma, representing thex andy coordinates of five points (1, 1), (2, 4), (3, 9), (4, 16), and (5, 25) in a two-dimensional space.
  • Theloadtxt()function loads text data into a NumPy array.

You should get the following output:

array([ 1., 1., 2., 4., 3., 9., 4., 16., 5., 25.])
  1. Convert the flat array into five points in 2D space:
txt = txt.reshape(5,2)
txt

After executing preceding code, you should see the following output:

array([[ 1., 1.], [ 2., 4.], [ 3., 9.], [ 4., 16.], [ 5., 25.]])
  1. Split the.txt variable intox andy axis co-ordinates:
x = txt[:,0]
y = txt[:,1]
print(x, y)

Here is the explanation for the preceding code block:

  • Separate thex andy axis points from thetxt variable.
  • x is the first column intxt andy is the second column.
  • The Python indexing starts from 0.

After executing the preceding code, you should see the following output:

[ 1. 2. 3. 4. 5.] [ 1. 4. 9. 16. 25.]

Reading from a .csv file

The.csv file has a relational database structure of rows and columns, and thetest.csv file hasx,y co-ordinates for five points in 2D space. Each point is a row in the file, with two columns:x andy. The same NumPyloadtxt() function is used to load data:

x, y = np.loadtxt ('test.csv', unpack = True, usecols = (0,1), delimiter = ',')
print(x)
print(y)

On execution of the preceding code, you should see the following output:

[ 1. 2. 3. 4. 5.] [ 1. 4. 9. 16. 25.]

Reading from an .xlsx file

Now let's read the same data from an.xlsx file and create thex andy NumPyarrays. The.xlsx file format is not supported by the NumPyloadtxt() function. A Python data processing package,pandas can be used:

  1. Read the.xlsx file into pandas DataFrame. This file has the same five points in 2D space, each in a separate row withx,y columns:
df = pd.read_excel('test.xlsx', 'sheet', header=None)
  1. Convert the pandas DataFrame to a NumPy array:
data_array = np.array(df)
print(data_array)

You should see the following output:

[[ 1 1] [ 2 4] [ 3 9] [ 4 16] [ 5 25]]
  1. Now extract thex andy coordinates from the NumPy array:
x , y = data_array[:,0], data_array[:,1]
print(x,y)

You should see the following output:

[1 2 3 4 5] [ 1 4 9 16 25]

Plotting the graph

After reading the data from any of the three formats (.txt,.csv,.xlsx) and format it tox andy variables, then we plot the graph using these variables as follows:

plt.plot(x, y)

Display the graph on the screen:

plt.show()

The following is the output obtained:

How it works...

Depending on the format and the structure of the data, we will have to use the Python, NumPy, or pandas functions to read the data and reformat it into an appropriate structure that can be fed into thematplotlib.pyplot function. After that, follow the usual plotting instructions to plot the graph that you want.

Changing and resetting default environment variables

Matplotlib uses thematplotlibrc file to store default values for various environment and figure parameters used across matplotlib functionality. Hence, this file is very long. Thesedefault values are customizable to apply for all the plots within a session.

You can use theprint(matplotlib.rcParams) command to get all the default parameter settings from this file.

Thematplotlib.rcParams command is used to change these default values to any other supported values, one parameter at a time. Thematplotlib.rc command is used to set default values for multiple parameters within a specific group, for example, lines, font, text, and so on. Finally, thematplotlib.rcdefaults() command is used to restore default parameters.

Thematplotlib.rcsetup()command is used internally by Matplotlibto validate that the parameters being changed are acceptable values.

Getting ready

The following code block provides the path to the file containing all configuration the parameters:

# Get the location of matplotlibrc file
import matplotlib
matplotlib.matplotlib_fname()

You should see the directory path like the one that follows. The exact directory path depends on your installation:

'C:\\Anaconda3\\envs\\keras35\\lib\\site-packages\\matplotlib\\mpl-
data\\matplotlibrc'

How to do it...

The following block of code along with comments helps you to understand the process of changing and resetting default environment variables:

  1. Import thematplotlib.pyplot package with theplt synonym:
import matplotlib.pyplot as plt
  1. Loadx andy variables from sametest.csv file that we used in the preceding recipe:
x, y = np.loadtxt ('test.csv', unpack = True, usecols = (0,1),
delimiter = ',')
  1. Change the default values for multiple parameters within the group'lines':
matplotlib.rc('lines', linewidth=4, linestyle='-', marker='*')
  1. Change the default values for parameters individually:
matplotlib.rcParams['lines.markersize'] = 20
matplotlib.rcParams['font.size'] = '15.0'
  1. Plot the graph:
plt.plot(x,y)
  1. Display the graph:
plt.show()

The following is the output that will be obtained:

How it works...

Thematplotlib.rc andmatplotlib.rcParams commands overwrite the default values for specified parameters as arguments in these commands. These new values will be used by thepyplot tool while plotting the graph.

It should be noted that these values will be active for all plots in the session. If you want different settings for each plot in the same session, then you should use the attributes available with theplot command.

There's more...

You can reset all the parameters to their default values, using thersdefaults() command, as shown in the following block:

# To restore all default parameters
matplotlib.rcdefaults()
plt.plot(x,y)
plt.show()

The graph will look as follows:

.

Download code iconDownload Code

Key benefits

  • Master Matplotlib for data visualization
  • Customize basic plots to make and deploy figures in cloud environments
  • Explore recipes to design various data visualizations from simple bar charts to advanced 3D plots

Description

Matplotlib provides a large library of customizable plots, along with a comprehensive set of backends. Matplotlib 3.0 Cookbook is your hands-on guide to exploring the world of Matplotlib, and covers the most effective plotting packages for Python 3.7. With the help of this cookbook, you'll be able to tackle any problem you might come across while designing attractive, insightful data visualizations. With the help of over 150 recipes, you'll learn how to develop plots related to business intelligence, data science, and engineering disciplines with highly detailed visualizations. Once you've familiarized yourself with the fundamentals, you'll move on to developing professional dashboards with a wide variety of graphs and sophisticated grid layouts in 2D and 3D. You'll annotate and add rich text to the plots, enabling the creation of a business storyline. In addition to this, you'll learn how to save figures and animations in various formats for downstream deployment, followed by extending the functionality offered by various internal and third-party toolkits, such as axisartist, axes_grid, Cartopy, and Seaborn. By the end of this book, you'll be able to create high-quality customized plots and deploy them on the web and on supported GUI applications such as Tkinter, Qt 5, and wxPython by implementing real-world use cases and examples.

Who is this book for?

The Matplotlib 3.0 Cookbook is for you if you are a data analyst, data scientist, or Python developer looking for quick recipes for a multitude of visualizations. This book is also for those who want to build variations of interactive visualizations.

What you will learn

  • Develop simple to advanced data visualizations in Matplotlib
  • Use the pyplot API to quickly develop and deploy different plots
  • Use object-oriented APIs for maximum flexibility with the customization of figures
  • Develop interactive plots with animation and widgets
  • Use maps for geographical plotting
  • Enrich your visualizations using embedded texts and mathematical expressions
  • Embed Matplotlib plots into other GUIs used for developing applications
  • Use toolkits such as axisartist, axes_grid1, and cartopy to extend the base functionality of Matplotlib

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date :Oct 23, 2018
Length:676 pages
Edition :1st
Language :English
ISBN-13 :9781789138665
Category :

What do you get with eBook?

Product feature iconInstant access to your Digital eBook purchase
Product feature icon Download this book inEPUB andPDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature iconDRM FREE - Read whenever, wherever and however you want

Contact Details

Modal Close icon
Payment Processing...
tickCompleted

Billing Address

Product Details

Publication date :Oct 23, 2018
Length:676 pages
Edition :1st
Language :English
ISBN-13 :9781789138665
Category :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99billed monthly
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconSimple pricing, no contract
$199.99billed annually
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconChoose a DRM-free eBook or Video every month to keep
Feature tick iconPLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick iconExclusive print discounts
$279.99billed in 18 months
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconChoose a DRM-free eBook or Video every month to keep
Feature tick iconPLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick iconExclusive print discounts

Frequently bought together


Matplotlib 3.0 Cookbook
Matplotlib 3.0 Cookbook
Read more
Oct 2018676 pages
Full star icon3 (5)
eBook
eBook
$9.99$39.99
$48.99
Mastering Matplotlib 2.x
Mastering Matplotlib 2.x
Read more
Nov 2018214 pages
eBook
eBook
$9.99$25.99
$32.99
Matplotlib for Python Developers
Matplotlib for Python Developers
Read more
Apr 2018300 pages
Full star icon2 (2)
eBook
eBook
$9.99$35.99
$43.99
Stars icon
Total$125.97
Matplotlib 3.0 Cookbook
$48.99
Mastering Matplotlib 2.x
$32.99
Matplotlib for Python Developers
$43.99
Total$125.97Stars icon
Buy 2+ to unlock$7.99 prices - master what's next.
SHOP NOW

Table of Contents

16 Chapters
Anatomy of MatplotlibChevron down iconChevron up icon
Anatomy of Matplotlib
Introduction
Working in interactive mode
Working in non-interactive mode
Reading from external files and plotting
Changing and resetting default environment variables
Getting Started with Basic PlotsChevron down iconChevron up icon
Getting Started with Basic Plots
Introduction
Line plot
Bar plot
Scatter plot
Bubble plot
Stacked plot
Pie plot
Table chart
Polar plot
Histogram
Box plot
Violin plot
Reading and displaying images
Heatmap
Hinton diagram
Contour plot
Triangulations
Stream plot
Path
Plotting Multiple Charts, Subplots, and FiguresChevron down iconChevron up icon
Plotting Multiple Charts, Subplots, and Figures
Introduction
Plotting multiple graphs on the same axes
Plotting subplots on the same figure
Plotting multiple figures in a session
Logarithmic scale
Using units of measurement
Developing Visualizations for Publishing QualityChevron down iconChevron up icon
Developing Visualizations for Publishing Quality
Introduction
Color, line style, and marker customization
Working with standard colormaps
User-defined colors and colormaps
Working with legend
Customizing labels and titles
Using autoscale and axis limits
Customizing ticks and ticklabels
Customizing spines
Twin axes
Using hatch
Using annotation
Using style sheets
Plotting with Object-Oriented APIChevron down iconChevron up icon
Plotting with Object-Oriented API
Introduction
Plotting a correlation matrix using pyplot and object-oriented APIs
Plotting patches using object-oriented API
Plotting collections using object-oriented API
Plotting with Advanced FeaturesChevron down iconChevron up icon
Plotting with Advanced Features
Using property cycler
Using Path effects
Using transforms
Taking control of axes positions
GridSpec for figure layout
Using origin and extent for image orientation
Geographical plotting using geopandas
Embedding Text and ExpressionsChevron down iconChevron up icon
Embedding Text and Expressions
Introduction
Using mathematical expressions with a font dictionary
Annotating a point on a polar plot
Using ConnectionPatch
Using a text box
Plotting area under an integral curve
Defining custom markers
Fractions, regular mathematical expressions, and symbols
Word embeddings in two dimensions
Saving the Figure in Different FormatsChevron down iconChevron up icon
Saving the Figure in Different Formats
Introduction
Saving the figure in various formats
Avoiding truncation while saving the figure
Saving partial figures
Managing image resolution
Managing transparency for web applications
Creating multi-page PDF reports
Developing Interactive PlotsChevron down iconChevron up icon
Developing Interactive Plots
Introduction
Events and callbacks
Widgets
Animation
Embedding Plots in a Graphical User InterfaceChevron down iconChevron up icon
Embedding Plots in a Graphical User Interface
Introduction
Using the Slider and Button Widgets of Matplotlib
Using the Slider and Button widgets of Tkinter GUI
Embedding Matplotlib in a Tkinter GUI application
Using the Slider and Button widgets of WxPython GUI
Embedding Matplotlib in to a wxPython GUI application
Using the Slider and Button widgets of Qt's GUI
Embedding Matplotlib in to a Qt GUI application
Plotting 3D Graphs Using the mplot3d ToolkitChevron down iconChevron up icon
Plotting 3D Graphs Using the mplot3d Toolkit
Introduction
Line plot
Scatter plot
Bar plot
Polygon plot
Contour plot
Surface plot
Wireframe plot
Triangular surface plot
Plotting 2D data in 3D
3D visualization of linearly non-separable data in 2D
Word embeddings
Using the axisartist ToolkitChevron down iconChevron up icon
Using the axisartist Toolkit
Introduction
Understanding attributes in axisartist
Defining curvilinear grids in rectangular boxes
Defining polar axes in rectangular boxes
Using floating axes for a rectangular plot
Creating polar axes using floating axes
Plotting planetary system data on floating polar axes
Using the axes_grid1 ToolkitChevron down iconChevron up icon
Using the axes_grid1 Toolkit
Introduction
Plotting twin axes using the axisartist and axesgrid1 toolkits
Using AxesDivider to plot a scatter plot and associated histograms
Using AxesDivider to plot a colorbar
Using ImageGrid to plot images with a colorbar in a grid
Using inset_locator to zoom in on an image
Using inset_locator to plot inset axes
Plotting Geographical Maps Using Cartopy ToolkitChevron down iconChevron up icon
Plotting Geographical Maps Using Cartopy Toolkit
Introduction
Plotting basic map features
Plotting projections
Using grid lines and labels
Plotting locations on the map
Plotting country maps with political boundaries
Plotting country maps using GeoPandas and cartopy
Plotting populated places of the world
Plotting the top five and bottom five populated countries
Plotting temperatures across the globe
Plotting time zones
Plotting an animated map
Exploratory Data Analysis Using the Seaborn ToolkitChevron down iconChevron up icon
Exploratory Data Analysis Using the Seaborn Toolkit
Introduction
Relational plots
Categorical plots
Distribution plots
Regression plots
Multi-plot grids
Matrix plots
Other Books You May EnjoyChevron down iconChevron up icon
Other Books You May Enjoy
Leave a review - let other readers know what you think

Recommendations for you

Left arrow icon
Debunking C++ Myths
Debunking C++ Myths
Read more
Dec 2024226 pages
Full star icon5 (1)
eBook
eBook
$9.99$31.99
$39.99
Go Recipes for Developers
Go Recipes for Developers
Read more
Dec 2024350 pages
eBook
eBook
$9.99$31.99
$39.99
50 Algorithms Every Programmer Should Know
50 Algorithms Every Programmer Should Know
Read more
Sep 2023538 pages
Full star icon4.5 (64)
eBook
eBook
$9.99$39.99
$49.99
$49.99
Asynchronous Programming with C++
Asynchronous Programming with C++
Read more
Nov 2024424 pages
Full star icon5 (1)
eBook
eBook
$9.99$33.99
$41.99
Modern CMake for C++
Modern CMake for C++
Read more
May 2024504 pages
Full star icon4.7 (13)
eBook
eBook
$9.99$39.99
$49.99
Learn Python Programming
Learn Python Programming
Read more
Nov 2024616 pages
Full star icon3.5 (2)
eBook
eBook
$9.99$35.99
$39.99
Learn to Code with Rust
Learn to Code with Rust
Read more
Sep 202557hrs 40mins
Full star icon5 (1)
Video
Video
$9.99$74.99
Modern Python Cookbook
Modern Python Cookbook
Read more
Jul 2024818 pages
Full star icon4.9 (17)
eBook
eBook
$9.99$43.99
$54.99
Right arrow icon

Customer reviews

Rating distribution
Full star iconFull star iconFull star iconEmpty star iconEmpty star icon3
(5 Ratings)
5 star20%
4 star20%
3 star20%
2 star20%
1 star20%
John C.May 20, 2021
Full star iconFull star iconFull star iconFull star iconFull star icon5
This is a well written and thorough survey of the Matplotlib library with a solid introduction to the Seaborn library. You don't need to know anything about Matplotlib to get started. It starts with plotting a line through two points on default axes and adds more and more features to the examples as the book progresses.That said, you DO need a basic competency in Python to understand the explanations. This is, after all, a library of extensions to the Python language.Super helpful is full code for all the examples available for download. You can read the discussion, experiment with the example code and really understand what's going on. You'll need the free open source Jupyter Python IDE to run the code, but Jupyter is probably the most frequently used platform for running Matplotlib, and it's ideal for this kind of hands on learning.
Amazon Verified reviewAmazon
SaurabhOct 02, 2019
Full star iconFull star iconFull star iconFull star iconEmpty star icon4
Matplotlib is tedious but you need to know it whether you are using pandas based plotting or seaborn.I like the fact that book is very detailed. I don't know of a better book right now to learn matplotlib. However, the approach uses a lot of state based plotting, which is no longer recommended. For example it uses a lot of plt.xticks() instead of ax.xticks() approach.Another problem is it does not show how to make plots using pandas data frame plot method. Since most people making plots today are using pandas, I'm disappointed that the data frame plot method was not covered.Overall this book is not for beginner python users. It will be appreciated more by intermediate python and pandas users.
Amazon Verified reviewAmazon
Student of the UniverseOct 23, 2022
Full star iconFull star iconFull star iconEmpty star iconEmpty star icon3
I've not a seasoned Python developer, so, when I purchased this book, I was pleased to see it has all the content I was interested in learning. I downloaded the code for this book from GitHub, worked through the first two chapters, and then in chapter 3, I ran into multiple errors right off. It appears that the book is out of date and the GitHub site is not updated for the latest Python 3 that is installed with Anaconda (I'm using the Mac). So, there is a chart where the author called out what is required for Windows 10. I will have to use Parallels on the Mac to see if that works. Pitty.
Amazon Verified reviewAmazon
Richard McClellanMay 15, 2019
Full star iconFull star iconEmpty star iconEmpty star iconEmpty star icon2
It is a pretty good book. The code examples are clear, and well explained.HOWEVER. This is 2019. You buy a programming book (I bought the Kindle version) you expect to be able to access the code. Usually on-line or a download. Since you can't cut and past out of Kindle, typing in examples is wholly last century.Well, there is a website (packt) that supposedly lets you download. 95mb zipped file later, I find that it is some combination of pdf's and png's of output. No code. Some mysterious IPYNB extension. So--a last century level, effectively. Last century you got a CD.It would be at least 4 stars if I could get at the code without having to type it all in.Two stars because it isn't entirely worthless.
Amazon Verified reviewAmazon
Adrian SavageApr 12, 2019
Full star iconEmpty star iconEmpty star iconEmpty star iconEmpty star icon1
This is, as it says, a cookbook. That is it give recipes for many different uses for Matplotlib. What it fails to do is to give any useful information as to the Matplotlib modules, the uses to which they can be put and the syntax of each command. In fact, should you wish to find out how a call such as Matplotlib.dates.DateFormatter works, you will not even find it in the index. In fact date and time are not in the index so in the 652 mostly useless pages of the book, you will struggle to make a graph with date/time on the x axis. As a cookbook its recipes are without taste or interest.
Amazon Verified reviewAmazon

People who bought this also bought

Left arrow icon
50 Algorithms Every Programmer Should Know
50 Algorithms Every Programmer Should Know
Read more
Sep 2023538 pages
Full star icon4.5 (64)
eBook
eBook
$9.99$39.99
$49.99
$49.99
Event-Driven Architecture in Golang
Event-Driven Architecture in Golang
Read more
Nov 2022384 pages
Full star icon4.9 (10)
eBook
eBook
$9.99$39.99
$49.99
$44.99
The Python Workshop Second Edition
The Python Workshop Second Edition
Read more
Nov 2022600 pages
Full star icon4.6 (19)
eBook
eBook
$9.99$41.99
$51.99
Template Metaprogramming with C++
Template Metaprogramming with C++
Read more
Aug 2022480 pages
Full star icon4.6 (13)
eBook
eBook
$9.99$37.99
$46.99
Domain-Driven Design with Golang
Domain-Driven Design with Golang
Read more
Dec 2022204 pages
Full star icon4.4 (18)
eBook
eBook
$9.99$35.99
$44.99
Right arrow icon

About the authors

Left arrow icon
Profile icon Poladi
Poladi
Srinivasa Rao Poladi has been in the IT services industry for over two decades, providing consulting and implementation services in data warehousing, business intelligence, and machine learning areas for global customers. He has worked with Wipro Technologies for two decades and played key leadership roles in building large technology practices and growing them to multi-million $ business. He spoke at international conferences, published many blogs and white papers in the areas of big data, business intelligence, and analytics. He is a co-founder of krtrimaIQ a consulting firm that provides cognitive solutions to create tomorrow's Intelligent Enterprises powered by automation, big data, machine learning, and deep learning.
Read more
See other products by Poladi
Profile icon Borkar
Borkar
Nikhil Borkar holds a CQF designation and a post Graduate Degree in Quantitative finance. He also holds the Certified Financial Crime examiner and Certified Anti-Money Laundering Professional qualifications. He is a registered Research Analyst with the Securities and Exchange Board of India (SEBI) and has a keen grasp of the Indian regulatory landscape pertaining to Securities and Investments. He is currently working as an independent FinTech and legal consultant. Prior to this, the worked with Morgan Stanley Capital International (MSCI) as a Global RFP Project Manager.
Read more
See other products by Borkar
Right arrow icon
Getfree access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook?Chevron down iconChevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website?Chevron down iconChevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook?Chevron down iconChevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support?Chevron down iconChevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks?Chevron down iconChevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook?Chevron down iconChevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.

Create a Free Account To Continue Reading

Modal Close icon
OR
    First name is required.
    Last name is required.

The Password should contain at least :

  • 8 characters
  • 1 uppercase
  • 1 number
Notify me about special offers, personalized product recommendations, and learning tips By signing up for the free trial you will receive emails related to this service, you can unsubscribe at any time
By clicking ‘Create Account’, you are agreeing to ourPrivacy Policy andTerms & Conditions
Already have an account? SIGN IN

Sign in to activate your 7-day free access

Modal Close icon
OR
By redeeming the free trial you will receive emails related to this service, you can unsubscribe at any time.

[8]ページ先頭

©2009-2025 Movatter.jp