Matplotlib For Python Developers
Craig Maloney writes "Ever since there was a collection of numbers, it seems that invariably someone will want a graph of those numbers. There are literally hundreds of different styles of graphs, and almost as many programs and tools to make those graphs. Matplotlib, a library and toolkit for the Python language, provides an easy and effective way to make some impressive graphics with little more than a smattering of Python. Matplotlib for Python Developers is equally impressive at distilling the core set of features of Matplotlib in a way that shows the reader how to get the most out the Matplotlib toolkit." Read below for the rest of Craig's review.
Matplotlib for Python Developers
author
Sandro Tosi
pages
291
publisher
Packt Publishing
rating
9/10
reviewer
Craig Maloney
ISBN
978-1-847197-90-0
summary
A comprehensive overview of the powerful Matplotlib Python library
Matplotlib for Python Developers begins with the customary introduction to the Matplotlib library. It includes where to download Matplotlib, as well as brief installation instructions for both Linux, Macintosh, and Windows platforms. The book then quickly moves to the next chapter, where the basic library functions are presented, via the interactive iPython shell. Each section of the chapter introduces a new part of the graph, with items like titles, grid lines, and labels being explained clearly and concisely. Also briefly presented are other useful libraries like numpy, as well as the various back-ends that Matplotlib supports. Chapter 3 continues the even pace, presenting more plot styles, and plot types, including polar graphs. These two chapters cover the fundamentals of Matplotlib very well, with each step clearly marked by what the graph should look like once completed.
The next chapter introduces more advanced plotting concepts that Matplotlib is capable of handling. The chapter begins with the three ways that Matplotlib may be used (The pyplot module, pylab, and the Object Oriented interface). From there, the book delves into subplots, multiple figures, additional axes, logarithmic axes, date plotting, contour plots, and image plots. Also included are sections on using LaTeX and TeX with Matplotlib, both for exporting graphs, as well as using TeX inside plots via Mathtext. By the end of the chapter, I felt very comfortable with the environment and the capabilities of Matplotlib, both as an interactive environment, and as a module for my own programs.
The next four chapters cover integrating Matplotlib with GTK+, QT4, wxWidgets, and web-based environments. The chapters for GTK+, QT4, and wxWidgets each begin by presenting a basic overview of the toolkit, and why one might want to use that particular toolkit. Next, the book shows how to embed a Matplotlib figure in a window, both with static and real-time data input. The book then shows how to use the toolkit's builder with Matplotlib (Glade for GTK+, QT Designer for QT4, and wxGlade for wxWidgets. The chapter on web development veers slightly from this format by showing several examples of using CGI and mod_python with Matplotlib before showing how to use Matplotlib with Django and Pylons.
The last chapter pulls together some "real world" examples together for the grand finale. The examples clearly show how Matplotlib would work for such plotting Apache web logs, fitting curves, and plotting geographic data. The geographic data plotting uses an additional module called basemap, which allows for plotting precisely on a map. This example floored me with the amount of power that Matplotlib possesses.
Overall, I found this book to be informative, without a lot of fluff. The organization of the book sometimes dipped into a chaotic presentation of "oh, look at this", but overall the author kept a very even pace, with clearly defined goals and clean resolution of those goals. Matplotlib for Python Developers is definitely a book that I would pick up to refresh my memory for using Matplotlib. The asking price is a bit steep for book that is just shy of 300 pages, but overall I highly recommend it for anyone looking to get started with this exceptional library. I'd also recommend it for anyone looking for alternatives to some of the other plotting packages available. Matplotlib is quite powerful, and Matplotlib for Python Developers makes this power very accessible.
You can purchase Matplotlib for Python Developers from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
The next chapter introduces more advanced plotting concepts that Matplotlib is capable of handling. The chapter begins with the three ways that Matplotlib may be used (The pyplot module, pylab, and the Object Oriented interface). From there, the book delves into subplots, multiple figures, additional axes, logarithmic axes, date plotting, contour plots, and image plots. Also included are sections on using LaTeX and TeX with Matplotlib, both for exporting graphs, as well as using TeX inside plots via Mathtext. By the end of the chapter, I felt very comfortable with the environment and the capabilities of Matplotlib, both as an interactive environment, and as a module for my own programs.
The next four chapters cover integrating Matplotlib with GTK+, QT4, wxWidgets, and web-based environments. The chapters for GTK+, QT4, and wxWidgets each begin by presenting a basic overview of the toolkit, and why one might want to use that particular toolkit. Next, the book shows how to embed a Matplotlib figure in a window, both with static and real-time data input. The book then shows how to use the toolkit's builder with Matplotlib (Glade for GTK+, QT Designer for QT4, and wxGlade for wxWidgets. The chapter on web development veers slightly from this format by showing several examples of using CGI and mod_python with Matplotlib before showing how to use Matplotlib with Django and Pylons.
The last chapter pulls together some "real world" examples together for the grand finale. The examples clearly show how Matplotlib would work for such plotting Apache web logs, fitting curves, and plotting geographic data. The geographic data plotting uses an additional module called basemap, which allows for plotting precisely on a map. This example floored me with the amount of power that Matplotlib possesses.
Overall, I found this book to be informative, without a lot of fluff. The organization of the book sometimes dipped into a chaotic presentation of "oh, look at this", but overall the author kept a very even pace, with clearly defined goals and clean resolution of those goals. Matplotlib for Python Developers is definitely a book that I would pick up to refresh my memory for using Matplotlib. The asking price is a bit steep for book that is just shy of 300 pages, but overall I highly recommend it for anyone looking to get started with this exceptional library. I'd also recommend it for anyone looking for alternatives to some of the other plotting packages available. Matplotlib is quite powerful, and Matplotlib for Python Developers makes this power very accessible.
You can purchase Matplotlib for Python Developers from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This is something that ought to be one chapter in a Python book, not another boat-anchor of a standalone book.
This book looks like a miracle cure for insomnia sufferers. Maybe I should show it to my doctor.
Well, as samzenpus already mentioned, the name of the book that I read was Matplotlib For Python Developers. It's about this library, a library for making graphs, and exporting graphs, and GTK+. Did I mention this book was written by a guy named Sandro Tosi? And published by the good people at Packt Publishing. So, in conclusion, on the Maloney scale of one to ten--ten being the highest, one being the lowest and five being average--I give this book a nine. Any questions?
It's probably just another case of absolutely non-technical marketing executives making a decision regarding what's mostly a technical matter. They're a problem in every industry, unfortunately, including publishing.
Although they don't understand the technical matters they're dealing with, they'll often make wide-ranging technical decisions anyways, even when these decisions make no sense and ultimately lead to total failure.
Books that should be 20 pages long end up being 250. Web sites that should be simple end up getting infested with shitty Flash animations. The truth gets thrown out in favor of bullshit. That's just marketing for you.
Wake me up when someone writes about Sillyplotadlib for Monty Python developers.
is it my imagination or has this been reviewed on slashdot before?
I've heard quite a few people here on Slashdot talk about how useful Python is as a substitute for MATLAB. Honestly, I don't get it. Python is trying to be a language for both hard core programming, and scientific programing. These two disciplines have very different needs. I don't want to load 20 modules before I can begin coding. I just want to input my algorithm and get a result I expect (not 5/2=2).
It seems that version 3.0 has gotten better for us scientific users. However, I think the programmers out there are now dissatisfied.
One of our competitors trademarked the term "hypothesis". From now on, we will call them "boneheaded ideas".
Python's dynamic object orientation allows it to be used for a wide range of rapid development in many fields.
I use it for scientific programming. While it does not have as many libraries as matlab or R, it is great because I can call R routines from python plus does things like threading and complex file manipulation, that the others do poorly.
Python is not bad numerically, you just have to be clear about what objects you are using when. If you don't want 5/2=2, then use 5./2.
Matplotlib is bar far the most difficult plotting package I have ever seen. You need to manually adjust every small detail of your plots including axes, tick marks, legends and even spacing for the various components in your plot. It's even worse than MATLAB. The API is difficult and documentation poor. The only sane reason to use Matplotlib is if you have a web application written in Python and need a plotting package that can handle numpy data structures.
No thanks. I have a better idea:
http://www.google.com/search?q=matplotlib
http://www.sigapl.org/whyapl.htm
Python threads seem to bring the C++ flamers out of the woodwork. Just so you know, Matplotlib is written in C++. I happen to like both languages.
SJW n. One who posts facts.
If you find matplotlib hard, try my Veusz python plotting package. It has a GUI you can build plots within. It is scriptable in python, and even the saved file format is a python script to generate the plot. It can read a variety of data formats.
At one point I was trying to decide which graphics plotting library I wanted to get proficient with. I considered mathplotlib but I eventually decided on R + ggplot and am very satisfied. Some examples here. True, I was doing mainly statistical stuff so the R connection wasn't a liability. But I like the philosophy of ggplot: the "gg" stands for "grammar of graphics". The library doesn't demand that you adjust every little thing separately to make interesting graphs; it gives you a variety of concepts (in ggplot parlance, geoms, layers, statistics, scales, etc.) and lets you combine them in arbitrary ways. It takes some getting used to but you end up being able to make great graphs without much twiddling with the details.
No word yet if the chapters are indented properly.
I have used matplotlib for journal plots and actually gave away a copy at a conference I ran so I have to say I really do like the book overall, but if you scan through the pages, you might be turned off.
Python has it's strengths, but there are good reasons Matlab is so widely used:
Price: There is a price to everything, Matlab's is up-front and what you get is guaranteed support and development. If there is a bug or serious shortcoming you know someone is working on it like their job depends on it. .Net calls can be made from the Matlab command line, integrating compiled C is well-supported and very straightforward. Python can do these things, but it's not automatic or well-documented.
Graphics: Matlab has the most feature-rich and usable graphical environment of any of its would-be competitors, none of which do 3D well.
Speed: Core Matlab operations are highly optimized in C; properly vectorized Matlab code will run much faster than what most programmers could write in C themselves.
Interoperability: Java and
Documentation: it's there, and it's good.
Dev Environment: the debugging tools, profiler, and lint integration are really helpful.
"The ability to delude yourself may be an important survival tool" - Jane Wagner -
I might ditch Matlab completely, especially given what I've read here, because I hate its license manager, it's expensive, and its performance on Macs is pretty sorry. Expenses can grow fast if you try to collaborate and nobody uses the same toolboxes. However, its syntax is intuitive to the mathematically inclined, it handles large arrays efficiently (!), and its GUI is really nice. I prefer Igor Pro for scientific graphing, but its syntax is a little more complex, it's limited to 4D arrays, and it's compiled. As long as someone else is buying, I'm glad to include Matlab in my work, but if I'm strapped for cash I might go with an octave/python/xmgrace combo.
He once inserted random mutations into his code, just so he could have the experience of debugging.
Isn't it fair to say that if you're worried about roundoff noise in repeated calculations, you've passed the point from being just a scientist to a someone who should be concerned with general programming theory and conventions, and hence at least familiar and comfortable with notation that denotes type?
My introduction to IEEE 754 was brought about via Python, when my chemistry kinetic simulations weren't running right (many millions of iterations, scaling factors with huge and tiny exponents). Understanding and fixing that problem took an hour or two, which far overshadowed the minute-long pause when I first found that 5/2 = 2.
In the end, the benefits of having the power of a real programming environment far outstrip the very small entry barrier. I personally feel that in the modern world you have no business calling yourself a scientist of any kind unless you can write a basic data manipulation script (parse and write a flatfile csv/tabs/CRLF etc) in some language of your choice. Massive quantities of data and meta-analyses are now the norm, making manual transcription or even copy/paste a thing of the past, and it is not acceptable to be hobbled by the feature set of existing software.
The ad attached to this story's RSS summary is for reptile cages.
There are some excellent IDEs for Python. They don't "come with" Python because they are big and somewhat platform dependent. Python IDEs that are useful for scientific work include Python(x,y), Sage, reInteract, and DrPython (you can find them on Google).
You're right that Python syntax is not perfectly adapted to scientific use, but I haven't found it to be a big deal. By being based on a general purpose language, however, you get a huge set of libraries that you simply can't get for MATLAB. And maybe Python will eventually adopt a couple more infix operators for common matrix operations.