Slashdot Mirror


Beginning Python Visualization

aceydacey writes "Sometimes a picture is worth a thousand words. Beginning Python Visualization: Creating Visual Transformation Scripts, published in February 2009 by Apress, shows how Python and its related tools can be used to easily and effectively turn raw data into visual representations that communicate effectively. The author is Shai Vaingast, a professional engineer and engineering manager who needed to train scientists and engineers to do this kind of programming work. He was looking for a tutorial and reference work, and unable to find a suitable text, wound up writing his first book. He writes in the easy and clear style of someone comfortable and engaged with the subject matter." Keep reading for the rest of aceydacey's review. Beginning Python Visualization: Crafting Visual Transformation Scripts author Shai Vaingast pages 363 publisher Apress rating 9/10 reviewer aceydacey ISBN 1430218436 summary learn how to process, organize, and visualize data from various sources using the Python language The book uses several very specific examples that illustrate general principles.

The first example is using GPS data. By using Python one can extract data from GPS receivers and enter it into the computer and manipulate it to do what one wants including creating graphs and charts. In this section he shows how to use CSV, comma separated values, as a most useful file format. He shows show to extract data from real world GPS devices and import it via serial ports and the PySerial module. It would be easy for the reader to duplicate and extend this project.

The heart of the book is coverage of useful examples utilizing MatPlotLib, NumPy and SciPy. These related tools are easy to use and fully integrated with Python. MatPlotLib is for plotting data and graphs, including interactive graphs and image files. NumPy is a powerful math library comparable to commercial tools like MatLab, and SciPy extends NumPy to for the sciences. Examples are numerous and include signal analysis using Fourier transforms.

There is also a section on Image Processing using PIL, the Python Imaging Library. This is used for relatively simple image cropping and sizing and also for bit by bit image processing. Interpolation and curve fitting are also well covered. For anyone wanting an introduction to graphical analysis of statistical data, this would be an excellent resource.

The author is obviously a professional in this field. He has a knack for good organizational style and a pragmatic approach to the work. In the book he says "Most of the time, research is organized chaos. The emphasis, however, should be on organized, not chaos." A real value I got from the book is a better understanding of data files, format, and organization as well as methods and guidelines for selecting file formats and storing and organizing data to enable fast and efficient data processing. It is obvious that this book was written by a practicing engineer.

The theme of the book is that Python can be an all purpose environment for data manipulation and visualization, using nothing but free and open source tools that are easily integrated and scriptable without using multiple programming languages. The book should be an invaluable tool for scientists and engineers but it is also easily accessible to anyone interested in math and data analysis. There is no need for an advanced math background. While, as a matter of full disclosure, I have undergraduate degrees in Math and Physics, I feel the book should be easily accessible to anyone with a solid high school math background who is seriously interested in the subject. The book contains a short introductory tutorial on the basics of Python so anyone familiar with programming in any language should be fine.

The book is an easy read from front to back, and I am sure it will also be a good reference resource for the future. The writing style is very clear and unforced and I found surprisingly few errors. While the Python world has a surplus of introductory and general books, books covering this kind of specific domain are especially welcome, and we could use more on other topics by competent authors.

At 363 pages the book is a surprisingly fast read. Its methodology is to use specific, short code examples to make all the key points. Most of the code samples are well selected, short and written in clear, concise Python. This is not the kind of book that overwhelms you with massive amounts of code. Either the book was well edited or else it was written by an exceptionally lucid thinker, or both.

So, if you want to learn how to process, organize, and visualize data from various sources using the Python language, I recommend this book to you. I have also posted a podcast of an interview with the author at Python411

You can purchase Beginning Python Visualization: Crafting Visual Transformation Scripts from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

9 of 46 comments (clear)

  1. Getting up and running by GlobalEcho · · Score: 5, Informative

    A great way to set yourself up with a Python-based analysis environment is a tool amalgamation called Python(x,y). I don't use it myself since my setup predates the project, but it has all the major tools I know and love.

    And for those of you who want statistical and graphing capabilities lacking there, know that you can communicate back and forth with an instance of GNU R, using rpy2.

    1. Re:Getting up and running by Anonymous Coward · · Score: 2, Informative

      All of these libraries are also include in Enthought's python distribution called EPD. While it is a commercial product, it is free for commercial use and there is also a 30-day free trial for anyone. EPD is available on platforms Python(x,y) doesn't cover.

    2. Re:Getting up and running by Anonymous Coward · · Score: 5, Informative

      Sage (http://www.sagemath.org) is also includes numpy, scipy, matplotlib, R, and many, many other packages. All of these are easily usable from a command line interface as well as an easy web interface (see http://www.sagenb.org)

      Mayavi should also be mentioned when talking about python and visualization: http://code.enthought.com/projects/mayavi/

      You can use Mayavi and Sage together as well. Here's a link to a public Sage worksheet illustrating how to use Mayavi to generate a 3d VRML interactive image embedded in the page: http://nb.hpfem.org/home/pub/16/ (install a X3D viewer like FreeWRL to see the last interactive image). Sage also does 3d graphing with JMOL.

  2. Re:really? by eldavojohn · · Score: 5, Informative

    are book reviews news?

    If you use the classic index, click here and select the no smoking column for book reviews. If you use the dynamic index, click here. In this view, find Exclusions under the dynamic index and click it. In the box for other terms, enter "book review" with the quotes and save it the page. Upon a page refresh of your home page, you should notice no more reviews of books.

    --
    My work here is dung.
  3. import tk? by zukinux · · Score: 2, Informative

    most of the people think that python GUI ends up with
    import tk
    and that's not correct at all, if you're among these people, you should read this book... good luck!

  4. CairoPlot by Anonymous Coward · · Score: 2, Informative

    There's a fairly new project called Cairoplot that creates charts and plots using Python and Cairo. It's not meant to do number-crunching like some of the other tools mentioned, but it creates great-looking charts.

    (Disclaimer: I've done a little bit of development on Cairoplot, trying to get it more LaTeX-friendly)

  5. Re:Fail already by shaiay · · Score: 2, Informative

    in the python csv module you can specify the delimiter (so it can be semicolons, or even tabs). I'm sure you, being so not n00b (what's the opposite of n00b anyway?), could write up a python function to quickly determine the delimiter used in a file. csv files are also nice in that they allow to surround text in quotes, thus allowing to include the delimiter as data in the field (i.e. "hello,",goodbye would give you two fields)

    Disclaimer: I know the author

  6. Re:Processing / "Visualizing Data" by kramulous · · Score: 2, Informative

    There is also The Visualization Handbook which covers all the different classifications of data and the appropriate techniques to visualise. Lots of theory and algorithms under the hood.

    --
    .
  7. Commas Suck by whitefox · · Score: 2, Informative

    Yes, I know commas are part of the CSV acronym but seriously they suck. A lot of the data I've worked with over the years (names, addresses, etc) was usually bound to have some records with embedded commas in the field values thus generating import exceptions.

    I learned early on to use tabs for any CSV exports I had to create. And Excel has no problem interpreting tab-delimited files.