Pages

Friday, July 10, 2015

Mastering matplotlib: Acknowledgments

The Book

Well, after nine months of hard work, the book is finally out! It's available both on Packt's site and Amazon.com. Getting up early every morning to write takes a lot of discipline, it takes even more to say "no" to enticing rabbit holes or herds of Yak with luxurious coats ripe for shaving ... (truth be told, I still did a bit of that).

The team I worked with at Packt was just amazing. Highly professional and deeply supportive, they were a complete pleasure with which to collaborate. It was the best experience I could have hoped for. Thanks, guys!

The technical reviewers for the book were just fantastic. I've stated elsewhere that my one regret was that the process with the reviewers did not have a tighter feedback loop. I would have really enjoyed collaborating with them from the beginning so that some of their really good ideas could have been integrated into the book. Regardless, their feedback as I got it later in the process helped make this book more approachable by readers, more consistent, and more accurate. The reviewers have bios at the beginning of the book -- read them, and look them up! These folks are all amazing!

The one thing that slipped in the final crunch was the acknowledgements, and I hope to make up for that here, as well as through various emails to everyone who provided their support, either directly or indirectly.

Acknowledgments

The first two folks I reached out to when starting the book were both physics professors who had published very nice matplotlib problems -- one set for undergraduate students and another from work at the National Radio Astronomy Observatory. I asked for their permission to adapt these problems to the API chapter, and they graciously granted it. What followed were some very nice conversations about matplotlib, programming, physics, education, and publishing. Thanks to Professor Alan DeWeerd, University of Redlands and Professor Jonathan W. Keohane, Hampden Sydney College. Note that Dr. Keohane has a book coming out in the fall from Yale University Press entitled Classical Electrodynamics -- it will contain examples in matplotlib.

Other examples adapted for use in the API chapter included one by Professor David Bailey, University of Toronto. Though his example didn't make it into the book, it gets full coverage in the Chapter 3 IPython notebook.

For one of the EM examples I needed to derive a particular equation for an electromagnetic field in two wires traveling in opposite directions. It's been nearly 20 years since my post-Army college physics, so I was very grateful for the existence and excellence of SymPy which enabled me to check my work with its symbolic computations. A special thanks to the SymPy creators and maintainers.

Please note that if there are errors in the equations, they are my fault! Not that of the esteemed professors or of SymPy :-)

Many of the examples throughout the book were derived from work done by the matplotlib and Seaborn contributors. The work they have done on the documentation in the past 10 years has been amazing -- the community is truly lucky to have such resources at their fingertips.

In particular, Benjamin Root is an astounding community supporter on the matplotlib mail list, helping users of every level with all of their needs. Benjamin and I had several very nice email exchanges during the writing of this book, and he provided some excellent pointers, as he was finishing his own title for Packt: Interactive Applications Using Matplotlib. It was geophysicist and matplotlib savant Joe Kington who originally put us in touch, and I'd like to thank Joe -- on everyone's behalf -- for his amazing answers to matplotlib and related questions on StackOverflow. Joe inspired many changes and adjustments in the sample code for this book. In fact, I had originally intended to feature his work in the chapter on advanced customization (but ran out of space), since Joe has one of the best examples out there for matplotlib transforms. If you don't believe me, check out his work on stereonets. There are many of us who hope that Joe will be authoring his own matplotlib book in the future ...

Olga Botvinnik, a contributor to Seaborn and PhD candidate at UC San Diego (and BioEng/Math double major at MIT), provided fantastic support for my Seaborn questions. Her knowledge, skills, and spirit of open source will help build the community around Seaborn in the years to come. Thanks, Olga!

While on the topic of matplotlib contributors, I'd like to give a special thanks to John Hunter for his inspiration, hard work, and passionate contributions which made matplotlib a reality. My deepest condolences to his family and friends for their tremendous loss.

Quite possibly the tool that had the single-greatest impact on the authoring of this book was IPython and its notebook feature. This brought back all the best memories from using Mathematica in school. Combined with the Python programming language, I can't imagine a better platform for collaborating on math-related problems or producing teaching materials for the same. These compliments are not limited to the user experience, either: the new architecture using ZeroMQ is a work of art. Nicely done, IPython community! The IPython notebook index for the book is available in the book's Github org here.

In Chapters 7 and 8 I encountered a bit of a crisis when trying to work with Python 3 in cloud environments. What was almost a disaster ended up being rescued by the work that Barry Warsaw and the rest of the Ubuntu team did in Ubuntu 15.04, getting Python 3.4.2 into the release and available on Amazon EC2. You guys saved my bacon!

Chapter 7's fictional case study examining the Landsat 8 data for part of Greenland was based on one of Milos Miljkovic's tutorials from PyData 2014, "Analyzing Satellite Images With Python Scientific Stack". I hope readers have just as much fun working with satellite data as I did. Huge thanks to NASA, USGS, the Landsat 8 teams, and the EROS facility in Sioux Falls, SD.

My favourite section in Chapter 8 was the one on HDF5. This was greatly inspired by Yves Hilpisch's presentation "Out-of-Memory Data Analytics with Python". Many thanks to Yves for putting that together and sharing with the world. We should all be doing more with HDF5.

Finally, and this almost goes without saying, the work that the Python community has done to create Python 3 has been just phenomenal. Guido's vision for the evolution of the language, combined with the efforts of the community, have made something great. I had more fun working on Python 3 than I have had in many years.

7 comments:

  1. Hmmm, I might need to pick this up so I can confidently recommend it for others in my science subcommunity. IDL is deeply entrenched as a visualization tool, and some of us have been chipping away at making python more widely in our little pocket. So much inertia. Maybe this book will drop the learning curve a bit.

    ReplyDelete
    Replies
    1. Jef, if you ever got the book, I hope you enjoyed it. I also *highly* recommend the French Onion dip.

      Delete
  2. Hi Duncan, really enjoying the level of detail in your book. Just two things:
    1-In the kindle edition there seems to be some issues where a new line is not created in some of the examples of your code (for instance in the first code "import matplotlib matplotlib.use('nbagg')" is rendered in the same line , I think this is a problem in the kindle conversion as the pdf is fine.
    2- Maybe something changed in matplotlib but in my setup with the updated packages, everytime I include %matplotlib inline, the plots are no longer rendered with the nbagg backend, they revert to the normal backend, searching on stackoverflow it seems that the new magic would be %matplotlib nbagg , this replaces the matplotlib.use('nbagg') and the %matplotlib inline and seems to work fine.
    Great job

    ReplyDelete
    Replies
    1. Thanks, Luis! This is great feedback -- I'll contact Packt today and let them know about the formatting issues with the .mobi.

      As for the other, what version of matplotlib are you using? I can update the notebooks with a comment to that effect, for anyone using later versions that 1.4.2 (which the notebooks were written against).

      So glad you're enjoying the book so far!

      Delete
    2. I am using matplotlib 1.4.3 with IPython 3.2.1 with a 64 bit version of python 3.4.1 in a windows 7 machine and it seems that the inline magic just overrides the use call, changing the order of the two call also doesn't seem to work since %matplotlib inline seems to prevent any further use of matplotlib.use(). Glad I could help.

      Delete
    3. Looking back into the issue it seems that %matplotlib nbagg doesn't solve all the problems, when using that magic all the plots end up being plotted in the first figure created (somehow new plt.plot() calls do not create a new figure instance), the solution seems to be to always create a new plt.figure() instance for each plot.

      Delete
  3. Hi there,

    Planning on buying the book soon, this sounds like what I've been looking for! However, are there plans to update this in the near future due to the release of mpl v1.5 or impending v2.0 release?

    Thanks!

    ReplyDelete

Note: Only a member of this blog may post a comment.