Ashwin Pajankar
Hands-on Matplotlib
Learn Plotting and Visualizations with Python 3
1st ed.
Logo of the publisher
Ashwin Pajankar
Nashik, Maharashtra, India
ISBN 978-1-4842-7409-5 e-ISBN 978-1-4842-7410-1
https://doi.org/10.1007/978-1-4842-7410-1
Ashwin Pajankar 2022
Apress Standard
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
This Apress imprint is published by the registered company APress Media, LLC part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY 10004, U.S.A.
This book is dedicated to the memory of my teacher, Prof. Govindarajulu Regeti (July 9, 1945, to March 18, 2021).
Popularly known to everyone as RGR, Prof. Govindarajulu obtained his B.Tech in electrical and electronic engineering from JNTU Kakinada. He also earned an M.Tech and a Ph.D. from IIT Kanpur. Prof. Govindarajulu was an early faculty member of IIIT Hyderabad and played a significant role in making IIIT Hyderabad the top-class institution that it is today. He was by far the most loved and respected faculty member of the institute. He was full of energy to teach and full of old-fashioned charm. There is no doubt he cared for every student as an individual, taking care to know about and to guide them. He taught, guided, and mentored many batches of students at IIIT Hyderabad (including the author of this book).
Introduction
I have been working in the domain of data science for more than a decade now, and I was introduced to Python more than 15 years ago. When I first worked with libraries such as NumPy, Matplotlib, and Pandas, I found it a bit tedious to comb through all the available literature in the form of printed books, video tutorials, and online articles, as most of them lacked comprehensive steps for beginners. It was then that I resolved to write a book, and I am glad that I could bring my resolution to life with the help of Apress.
This book is the result of thousands of hours (in addition to the ones spent writing the actual book) going through technical documentation, watching training videos, writing code with the help of different tools, debugging faulty code snippets, posting questions and participating in discussions on various technical forums, and referring to various code repositories for pointers. I have written the book in such a way that beginners will find it easy to understand the topics. The book has hundreds of code examples and images of code output so that you can fully understand each concept introduced. All the code examples are explained in detail.
The book begins with a general discussion of Python and a small guide explaining how to install it on various computing platforms such as the Windows OS and Linux computers (like the Raspberry Pi). We then move on to discussing the scientific ecosystem. Then we focus on NumPy, which is the fundamental library for numerical computing. We specifically focus on the multidimensional, array-like data structure of NumPy, called the Ndarray. We then explore data visualization libraries, such as Matplotlib and Plotly, to learn how to plot Ndarrays.
Most of the chapters explore the data visualization library Matplotlib. You will learn a lot of data visualization tips and techniques in these chapters.
Then we dive into Pandas so you can learn about its important data structures, called the series and dataframe. Midway through the book, you will also learn how to read data from various data sources using Python, NumPy, Matplotlib, and Pandas. You will also learn how to visualize Pandas data with popular visualization libraries such as Matplotlib and Seaborn, as well as how to work with time-indexed data.
On an ending note, we started and finished working on this project at a very turbulent time (the beginning of 2021) marked by hardships such as hospitalization and deaths of friends, social unrest, lockdowns, curfews, economic slowdown, and a host of other sociopolitical problems brought about in part by the COVID-19 pandemic. I myself was hospitalized due to severe complications from pneumonia and breathing troubles caused by a COVID-19 infection. It delayed the launch of this long-planned project. To be frank, working on this book with the help of my longtime mentors at Apress (Celestin, James, and Aditee) offered me a sense of purpose in these troubled times. I end this introduction with a note of hope and positive words that we, as a society and a global civilization, will overcome these turbulent times with the help of each other, and I look at the future with a lot of hope and bright eyes.
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/978-1-4842-7409-5. For more detailed information, please visit www.apress.com/source-code.
Acknowledgments
I would like to thank Celestin and Aditee for giving me an opportunity to share my knowledge and experience with readers. I thank James Markham for helping me to shape this book according to Apress standards. I am in debt to the technical reviewer for helping me to improve this book. I also thank Prof. Govindrajulu Sirs family, Srinivas (son) and Amy (daughter in law), for allowing me to dedicate this book to his memory and for sharing his biographical information and photograph for publication. I would also like to thank all the people at Apress who were instrumental in bringing this project to reality.
Table of Contents
About the Author
Ashwin Pajankar
earned a Master of Technology in computer science engineering from IIIT Hyderabad and has more than 25 years of experience in the area of programming. He started his journey in programming and electronics at the tender age of 7 with the BASIC programming language and is now proficient in Assembly programming, C, C++, Java, shell scripting, and Python. His other technical expertise includes single-board computers such as the Raspberry Pi and Banana Pro, microcontroller boards such as the Arduino, and embedded boards such as the BBC Micro Bit.
He is currently a freelance online instructor teaching programming to more than 70,000 professionals. He also regularly conducts live programming bootcamps for software professionals. His growing YouTube channel has an audience of more than 10,000 subscribers. He has published more than 15 books on programming and electronics.