Quantcast
Channel: Planet Plone - Where Developers And Integrators Write
Viewing all articles
Browse latest Browse all 3535

Alex Clark: Matplotlib Plotting Cookbook Review

$
0
0

I was given a copy ofMatplotlib Plotting Cookbook by Alexandre Devertand asked to review it. Thanks PACKT!Here is my review.

Preface

But first, I'll mention I've worked on two projects recently that involved rendering matplotlib graphs directly to the browser i.e. via content-type: image/png. This is fun! It's particularly enjoyable when you are trying to avoid performing the task "the right way", which is arguably outputting JSON to some JavaScript graphing library e.g. Highcharts. The dependencies are heavy i.e. pip install numpy, etc. but not that heavy and once they are installed, your web application can output graphs rivaling those produced by JavaScript, all written in Python[1]. Highly recommended!

Chapter 1

I think the code examples in Chapter 1 alone are worth the price of admission. Here is a video of me walking through the Chapter 1 code examples:

You'll notice the typical fare here: bar, line and pie graphs along with some more complex boxplot, histogram, horizontal bar, scatter and triangle graphs, all in various colors. For reference, here are the excerpted commands called to produce these graphs:

Chapter 2

Chapter 2 is all about customization e.g. via matplotlibrc. Here is a video of me walking through the Chapter 2 code examples:

For reference, here is the sample matplotlibrc included with the matplotlib distribution (lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc):

As you can see, there are a lot of knobs you can turn here.

Chapter 3

Chapter 3 is all about "annotations". Here is a video of me walking through the Chapter 3 code examples:

"Annotations" includes related topics such as adding shapes and controlling tick spacing and labeling.

Chapter 4

Chapter 4 is all about "working with figures". Here is a video of me walking through the Chapter 4 code examples:

"Working with figures" includes obvious topics like subplot and less obvious topics like setting the aspect ratio.

Chapter 5

Chapter 5 is all about "working with file output". For reference, here are some of the images produced by the examples in this chapter (I wrote jpg files instead of png files due to a problem with my libpng: RuntimeError: Could not create write struct.)

Also covered in this chapter is pdf output.

Chapter 6

Chapter 6 is all about "working with maps".

This chapter also introduces the imshow command.

Chapter 7

Chapter 7 is all about "working with 3D figures".

For reference, here are the excerpted commands called to produce these graphs:

Chapter 8

Chapter 8 is all about working with the "user interface" interactively.

Additionally, all of the popular graphical windowing environments are discussed: Tkinter, wxWidgets, GTK, Pyglet (three out of four of which I was able to install; GTK 2 vs GTK 3 confused me and I ran out of time debugging it.

Conclusion

Overall I enjoyed this book and would recommend buying it.

(You should probablyhire meorfollow me on Twitteror both. And speaking of PACKT, you should definitelybuy my book too.)

[1]Yes, I'm familiar with Bokeh.

Viewing all articles
Browse latest Browse all 3535

Trending Articles