Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Matplotlib 3.0 Cookbook
Matplotlib 3.0 Cookbook

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

By Srinivasa Rao Poladi , Nikhil Borkar
€37.99
Book Oct 2018 676 pages 1st Edition
eBook
€28.99 €19.99
Print
€37.99
Subscription
€14.99 Monthly
eBook
€28.99 €19.99
Print
€37.99
Subscription
€14.99 Monthly

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Black & white paperback book shipped to your address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now
Estimated delivery fee Deliver to Italy

Premium delivery 7 - 10 business days

€23.95
(Includes tracking information)

Product Details


Publication date : Oct 23, 2018
Length 676 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781789135718
Category :
Table of content icon View table of contents Preview book icon Preview Book

Matplotlib 3.0 Cookbook

Anatomy of Matplotlib

This chapter begins with an introduction to Matplotlib, including the architecture of Matplotlib and the elements of a figure, followed by the recipes. The following are the recipes that will be covered in this chapter:

  • Working in interactive mode
  • Working in non-interactive mode
  • Reading from external files and plotting
  • How to change and reset default environment variables

Introduction

Matplotlib is a cross-platform Python library for plotting two-dimensional graphs (also called plots). 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, complex dashboard 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, and scripting, 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 in pygtk, wxpython, tkinter, qt4, or macosx, and so on, also referred to as interactive backends) and hard-copy backends to make image files (.png, .svg, .pdf, and .ps, also referred to as non-interactive backends). We will learn how to configure these backends in later Chapter 9, Developing Interactive Plots and Chapter 10, Embedding Plots in a Graphical User Interface.

Artist layer

This is the middle layer of the stack. Matplotlib uses the artist 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 an object-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 a pyplot API.

Elements of a figure

The high-level Matplotlib object that contains all the elements of the output graph is called a figure. 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 a figure, 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 a title, an x-label and a y-label. A figure can have many such axes, each representing one or more graphs. In the preceding figure, there is only one axes, 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 an x axis and a y axis, and three-dimensional graphs have an x axis, a y axis, and a z 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, x axis label, y axis label, graph label (blue signal/red signal in the preceding figure Anatomy of a figure), and so on.

Legend

When there are multiple graphs in the axes (as in the preceding figure Anatomy 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 the axes. The figure 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, or z) will have a range of values that are divided into many equal bins. Bins are chosen at two levels. In the preceding figure Anatomy of a figure, the x axis 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 called major ticks and minor bins are called minor ticks, and the names given to them are major ticklabels and minor ticklabels.

Spines

Boundaries of the figure are called spines. 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 the x and y axis. In the preceding figure, the grid is shown in dashed lines.

Working in interactive mode

Matplotlib can be used in an interactive or non-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 mode ON
  • matplotlib.pyplot.ioff() to switch OFF the interactive mode
  • matplotlib.is_interactive() to check whether the interactive mode is ON (True) or OFF (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 the matplotlib and pyplot libraries. It is common practice in Python to import libraries with crisp synonyms. Note plt is the synonym for the matplotlib.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 as True.
  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).
  • The plot command expects two arguments (Python list, NumPy array or pandas DataFrame) for the x and y axis respectively.
  • If only one argument is passed, it takes it as y axis co-ordinates and for x 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 as y axis coordinates.
  • For the x 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 for y, then for x, it would take the range of 0 to 2.
  • You should see the graph like the one shown in step 6.
  • plt.title("Interactive Plot"), prints the title on top of the graph as Interactive Plot.
  • plt.xlabel("X-axis"), prints the x axis label as X-axis.
  • plt.ylabel("Y-axis"), prints the y axis label as Y-axis.
  • After executing preceding three statements, you should see the graph as shown in step 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 the x axis label, and finally the y 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 Matplotlib or certain backends (such as macosx), the graph may not be updated immediately. In such cases, you need to call plt.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 the matplotlib and pyplot 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 output False.
  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 call plt.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 calling plt.show() command explicitly. However, in Python shell or embedded applications, plt.show() or plt.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 the matplotlib.pyplot, numpy , and pandas packages that are required to read the input files:

  1. Import the pyplot library with the plt synonym:
import matplotlib.pyplot as plt
  1. Import the numpy library with the np synonym. The numpy library can manage n-dimensional arrays, supporting all mathematical operations on these arrays:
import numpy as np
  1. Import the pandas package with pd 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 the txt variable:
txt = np.loadtxt('test.txt', delimiter = ',')
txt

Here is the explanation for the preceding code block:

  • The test.txt text file has 10 numbers separated by a comma, representing the x and y coordinates of five points (1, 1), (2, 4), (3, 9), (4, 16), and (5, 25) in a two-dimensional space.
  • The loadtxt() 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 into x and y axis co-ordinates:
x = txt[:,0]
y = txt[:,1]
print(x, y)

Here is the explanation for the preceding code block:

  • Separate the x and y axis points from the txt variable.
  • x is the first column in txt and y 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 the test.csv file has x, y co-ordinates for five points in 2D space. Each point is a row in the file, with two columns: x and y. The same NumPy loadtxt() 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 the x and y NumPy arrays. The .xlsx file format is not supported by the NumPy loadtxt() 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 with x, 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 the x and y 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 to x and y 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 the matplotlib.pyplot function. After that, follow the usual plotting instructions to plot the graph that you want.

Changing and resetting default environment variables

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

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

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

The matplotlib.rcsetup() command is used internally by Matplotlib to 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 the matplotlib.pyplot package with the plt synonym:
import matplotlib.pyplot as plt
  1. Load x and y variables from same test.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...

The matplotlib.rc and matplotlib.rcParams commands overwrite the default values for specified parameters as arguments in these commands. These new values will be used by the pyplot 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 the plot command.

There's more...

You can reset all the parameters to their default values, using the rsdefaults() 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:

.

Left arrow icon Right arrow icon
Download code icon Download 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.

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

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Black & white paperback book shipped to your address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now
Estimated delivery fee Deliver to Italy

Premium delivery 7 - 10 business days

€23.95
(Includes tracking information)

Product Details


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

Table of Contents

17 Chapters
Preface Chevron down icon Chevron up icon
1. Anatomy of Matplotlib Chevron down icon Chevron up icon
2. Getting Started with Basic Plots Chevron down icon Chevron up icon
3. Plotting Multiple Charts, Subplots, and Figures Chevron down icon Chevron up icon
4. Developing Visualizations for Publishing Quality Chevron down icon Chevron up icon
5. Plotting with Object-Oriented API Chevron down icon Chevron up icon
6. Plotting with Advanced Features Chevron down icon Chevron up icon
7. Embedding Text and Expressions Chevron down icon Chevron up icon
8. Saving the Figure in Different Formats Chevron down icon Chevron up icon
9. Developing Interactive Plots Chevron down icon Chevron up icon
10. Embedding Plots in a Graphical User Interface Chevron down icon Chevron up icon
11. Plotting 3D Graphs Using the mplot3d Toolkit Chevron down icon Chevron up icon
12. Using the axisartist Toolkit Chevron down icon Chevron up icon
13. Using the axes_grid1 Toolkit Chevron down icon Chevron up icon
14. Plotting Geographical Maps Using Cartopy Toolkit Chevron down icon Chevron up icon
15. Exploratory Data Analysis Using the Seaborn Toolkit Chevron down icon Chevron up icon
16. Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela