April 2012


This book is written by Shruti Jauhari, a noted Hindustani Classical Singer and a disciple of K.J.Yesudas. The book is an accessible introduction to the various elements of Hindustani Classical Music. To read a language, you need to know the alphabets and the grammar associated with it. In the same way, to listen to Hindustani music, you need to have a basic knowledge of Svar,Raag and Taal   One often comes across terms like bandish, gharana, alap, vilambit , taal, etc in the context of Hindustani Music. Unless one has some understanding of these terms, it is difficult to be a discerning listener.

There are very few books written in English that give a sufficient knowledge with out entering the intricacies of the subject. This book belongs to such a category, where a beginner gets a good 1000 ft. view of the various aspects of Hindustani Music.  It starts off with a basic history of Hindustani music in India to give a reader some idea about the way music and musical ideas developed . The book then goes in to explaining terms such as Sruti, Svar, Musical Scale, That , Raag, Taal, Laya in an intuitive manner showing the basic math behind it.

There is a chapter that gives an intro in to the basic singing process and tries to provide simple answers to questions like, what constitutes a rendition, what are the parts of a typical rendition, where does an artist get to innovate, what is the role of tabla player in a rendition etc. The book then goes in to a basic description of various gharanas. In the modern world where learning is from a guru whoever is accessible in the city or town that one lives, gharanas might not be relevant. But it is always nice to know the various gharanas and the artists associated with various gharanas. The book also lists some eminent Musicologists and their profiles.

Perhaps the most useful chapter to me in the book is a full fledged description of the prominent raagas and their attributes. Well listening to raagas is one thing but singing or playing is a completely different thing. Unless you are thoroughly aware of the structure of a raag, it is very difficult to play beyond the known composition. Your guru might teach you a few compositions in a specific raag. Playing the given composition is a matter of practice. But soon one realizes the real fun in playing lies in improvisation. I play about 7 raagas on Sitar and  I maintain a chart that gives the attributes of these raagas. Sometimes the way that I maintain the chart for a specific raaga is not very systematic. This chapter has taught me a nice way to structure the chart. It has a chart for each of the 25 most popular raagas in Hindustani Music. I doubt I will ever play so many raagas in my life time!, but I guess I will refer to the structured chart given in this book from time to time.



Getting good at any craft takes a long time, be it deal making or trading or mastering a game or programming. However books/articles,etc. out in the world are stufffed with "get rich quick", "get smart quick","get skills quick" kind of messages. I can’t speak of other fields but programming books, that implicitly carry these messages, are always in majority, be it in the offline and online bookstores. ‘Learn XYZs language in 30 days’, ‘Become an ace coder in X weeks’ etc. For all such coders who believe such books and coding something for 30 days is going to transform you, make your venture the next instagram, this book has a lot to offer. Steve Martin gives a biographical account of his life where he claims his achievement is not a result of some sudden random event that got him to spotlight and has since then remained in spotlight. Far from it, its a story of sweat, tears, rejections and occasional acceptances, smiles and rewards . Steve starts off his book saying

I did Stand-Up comedy for eighteen years.Ten of those years were spent learning, four years were spent refining, and four were spent in wild success. I was seeking comic originality, and fame fell on me as a by-product. The course was more plodding than heroic. I did not strive valiantly against doubters but took incremental steps studded with a few intuitive leaps. I was not naturally talented. I didn’t sing, dance, or act, though working around that minor detail made me inventive. I was not self-destructive, though I almost destroyed myself.

The book gives a background of Steve’s father whose career ambition to be an actor made the family move from Texas to Hollywood to California. Amidst the various road trips, car radio introduced Steve to comedy. Later TV shows hooked him on to comedy. Meanwhile his father’s acting gig was going nowhere and he reconciled to working in real estate, yielding to the pressures of raising a family. He was forever against Steve’s interest in comedy as he thought it was flippant job. So, Steve’s childhood , despite a doting mother was a troubled childhood. Somewhere in the book he remarks,

I have heard it said that a complicated childhood can lead to a life in the arts. I tell you this story of my father and me to let you know I am qualified to be a comedian.

Thanks to his father’s decision to move to Inglewood, California, Steve finds himself a job at Disneyland, the fairy tale place for any kid. His job was selling guide books. His job used to get over by noon and he had a free admission in the park. During this free time he came in contact with magic and he was enthralled by it. At the age of 10 being a regular employee at Disneyland, he learnt magic tricks from a fellow named Eddie Adamek. He was completely fascinated by one, Wally Boag, a performing artist at Disneyland. Slowly he starts attending every show of Wally Boag and tries to absorb all aspects of his performance. This stint in Disneyland comes to an end, thanks to poor sales of guide books. Steve then works on an ad-hoc job for an year before knocking the doors of local magic shops and he gets a job at one such shops. Thus, Steve began his show business career at the age of fifteen in 1960. He stood behind a counter eight hours a day, shuffling decks, manipulating Wizard decks , Mental Photography cards, and performing other magic tricks. This practice for 8 to 12 hours each day made him better and better at magic. He also developed a keen interest towards comedy after seeing Wally Boag’s performance. He also starts reading various magic books and devours for magic tricks that he can use at work.While performing his magic tricks, he realizes that audience loved it when some tricks didn’t work. This is when he faces a choice in his life, either be a magician or do comedy. Given that advanced magic tricks required more money, stage lighting infra etc, he takes a decision of somehow mixing comedy and magic so that he stands out.

Steve remarks,

At age eighteen, I had absolutely no gifts. I could not sing or dance, and the only acting I did was really just shouting. Thankfully, perseverance is a great substitute for talent. Despite a lack of natural ability, I did have the one element necessary to all early creativity: naïveté that fabulous quality that keeps you from knowing just how unsuited you are for what you are about to do.

He also starts learning banjo. Magic by itself might be a common place. Comedy by itself might be a regular event. But mix magic , comedy and banjo, you get a combination that will make a person stand out in any performance. That’s exactly what Steve aimed for. When he picked banjo he had no teacher, he literally learnt by slowing down banjo records. When asked in a Charlie Rose interview, about his thoughts on banjo, Steve remarked,

In high school, I couldn’t  play an instrument, I remember getting my first banjo, and reading the book saying saying his is how you play the C chord, and I put my fingers down to play the C chord and I couldn’t tell the difference. But I told myself, just stick with this, just keep playing, and one day you’ll have been playing for 40 years, and at this point, you’ll know how to play.

He indeed got better as he kept playing and practicing.In 2009, Steve released his first album, ‘The Crow’ and it won a Grammy…Ok, Back to the story now.

Steve started working at ‘Bird Cage Theatre’ at the age of eighteen with no specific skill set, except an ambition to become good at comedy. He worked at Bird Cage Theatre four years mastering the craft.He worked steadily on his magic act, six minutes at a time, four times a day, five on Sunday, for three years. That’s a ton of practice. Even though he relied less on magic in the later years, he says that the ability to judge audience reaction from all those magic shows was priceless. At Bird Cage Theatre, Steve starts using banjo in his act and tweaks his show sometimes to rely purely on comedy.While working at Bird Cage, he also starts doing part time at another theatre, ‘Prison of Socrates’. About these formative years of experience, Steve remarks

My act was eclectic, and it took ten more years for me to make sense of it. However, the opportunity to perform four and five times a day gave me confidence and poise. Even though my material had few distinguishing features, the repetition made me lose my amateur rattle.

Steve consciously starts restricting magic to one specific act so that he doesn’t carry of risk of being called a magician. He wanted to be a comedian and not a magician. Really Amazing, the kind of clarity he had at such a young age. Well , he had a parallel life going on too. He got himself enrolled in a state college and started reading about Philosophy, ethics , logic. Not surprisingly, he found content for his comedy acts in these courses. Like they say, if you want to buy a car, you suddenly start noticing cars on the street. In the same way, Steve’s liking for comedy made his courses on syllogism , philosophy etc, a wonderful source for his comedy acts. During these years where he was doing multiple things, he had two illuminating moments, one he decided he would write his own comedy and second, he met Nina Goldbatt who had a significant impact on his professional life. Courtesy Nina, he later got a break in the then popular show, Smother brothers show. It is not a fairy tale story after this break at Smother brothers show. Steve met with a lot of failures, experimented a lot as the material was getting obsolete very quickly. He continued to study, despite the hectic schedule and that kept his mind afresh. He could rely on the study time to energize him to come up with creative content for his acts. He improved on the comedy format where he cut off the reliance on punch lines to make the audience laugh. He improvised and developed his unique style where the act free flowing in nature.

Steve summarized his eight years on this job,

My goal was to make the audience laugh but leave them unable to describe what it was that had made them laugh. In other words, like the helpless state of giddiness experienced by close friends tuned in to each other’s sense of humor, you had to be there. And for the next eight years, I did that

After this eight year stint, Steve left television writing and hit the road, literally. He went on a string of road shows designed by a local agency and here is where he honed his skills as a comedian. The anonymity made him brave enough to experiment in colleges and small towns. This was also a time when he was away completely from his parents and sister. This act of doing, experimenting, getting feedback, learning from it and improvising is the classic "deliberate practice act", that he went through, during his years on the road. He also emphasizes the role of solitude in those years and says that it was a crucial element for becoming good at his craft.

He remarks,

The travel isolated me. Friends were available only through costly phone calls, and contact with my parents and sister spiraled down to a pinpoint. In this netherworld, I was free to experiment. These out-of-the-way and varied places provided a tough comedy education. There were no mentors to tell me what to do; there were no guidebooks for doing stand-up. Everything was learned in practice, and the lonely road, with no critical eyes watching, was the place to dig up my boldest, or dumbest, ideas and put them on stage. Because I was generally unknown, in the smaller venues I was free to gamble with material, and there were a few evenings when crucial mutations affected my developing act. THE CONSISTENT WORK enhanced my act. I learned a lesson: It was easy to be great. Every entertainer has a night when everything is clicking. These nights are accidental and statistical: Like lucky cards in poker, you can count on them occurring over time. What was hard was to be good, consistently good, night after night, no matter what the abominable circumstances.

So, these years spent on creating, refining, experimenting the craft made the Steve Martin that he is, today. Starting from a job at ‘Coffee and Confusion’ where he had to talk to empty chairs just to attract passerby, he went on to doing comedy act for as large as 45000 jam packed auditorium. I have not been able to touch upon a lot of other subtle aspects that are mentioned in the book, that one can apply to developing skills in any craft. I guess one needs to read this book to get all the flesh and bones of the story.

takeawaTakeaway :
The basic theme that one can infer from Steve Martin’s story is Diligence. His diligence played a pivotal role in his success. Diligence not just in terms of persistence, but also in the ability to ignore unrelated pursuits.


It has been a long time since I have read any fiction book. So, thought of reading one, on this weekend to take a break from stats, programming and the usual routine. It took me about 9 hours to read the entire book and I must say that there was not a single instance during those 9 hours that I felt like taking a break. So, the book has a smooth flow of prose with just enough characters that you don’t lose the story or get bored anywhere. The plot has about 15 characters , including one played by the author himself, Somerset Maugham but not all 15 characters get the same footage(obviously) .The protagonist of the story is Laurence Larry Darrell who goes on a spiritual quest and the book tries to weave a story around that quest. The other 13 characters come and go in with varying periodicity through out the book. Besides Larry, the main characters in the story are Isabel who loves Larry but ends up marrying Gray Maturin, Elliott Templeton, Isabel’s uncle whose sole purpose in life is to socialize and be at parties, Sophie MacDonald, a poetess turned whore turned dope addict, whom Larry almost ends up getting married, but thanks to a Isabel’s devious plan, never does so.

The story starts off with Larry being engaged to Isabel. After a stint in the army, Larry is a changed man. He wants to understand about God, Evil, role of knowledge in salvation and whole lot of things that any spiritually inclined person would seek. The difference though is that many of us, answer or seek answers to these questions, while keeping a day job, holding the responsibilities of a spouse, a parent etc. Not Larry. He has no intention to work and he tries to argue with Isabel, that in his meager income they can live a decent life. Despite Isabel deeply in love with Larry, she rejects him. I guess for some people, economic considerations weigh far more than matters of the heart, when it comes to settling down with somebody. Isabel gets married to a business magnet,Gray Maturin. Larry then goes on a quest that takes him to Germany, Spain and India. He finally gets some clarity after staying in India at an Ashram for a few years and meeting some spiritually inclined people in India.

The book does have a dose of aspects from Hinduism like karma, renunciation, rebirth, etc. But the author makes it clear that he never intends of summarizing or even talking at length about such aspects in his book. He is clear about his role, i.e a storyteller. I must say he has played his role as a character and as an author with perfection , as he make spiritual elements, the various locations , a dozen characters as props to show the conversion of an atheist Larry to a devout spiritual person by the end of the book. No wonder this book is rated as one of the finest works of Somerset Maugham. However the movie adaption met with a commercial failure.

Some quotes / conversation that I found interesting amongst the various characters in the novel are :

  • I have been reading Spinoza the last month or two. It fills me with exultation. It’s like landing from your plane on a great plateau in the mountains. Solitude, and an air so pure that it goes to your head like wine and you feel like million dollars
  • What are you do going to do with all this unnecessary knowledge which you call wisdom ? It I ever acquire wisdom I suppose I shall be wise enough to know what to do with it
  • I wish I could make you see how much fuller the life I offer you is than anything you have a conception of. I wish I could make you see how exciting the life of spirit is and how rich in experience. It’s illimitable. It’s such a happy life. There’s only one thing like it, when you are up in a plane by yourself, high, high and only infinity surrounds you.You are intoxicated by the boundless space. You feel such a sense of exhilaration that you wouldn’t exchange it for all the power and glory in the world.
  • Unfortunately sometimes one can’t do what one thinks is right without making someone else unhappy
  • What’s the good of knowledge if you are not going to do anything with it ? Perhaps it will be sufficient satisfaction merely to know, as it’s a sufficient satisfaction to an artist to product a work of art. And perhaps its only a step towards something further
  • Love isn’t a good sailor and it languishes on a sea voyage. You will be surprised when you have the Atlantic between you and Larry to find how slight the pang is that before you sailed seemed intolerable
  • Most people when they are in love invent every kind of reason to persuade themselves that its only sensible to do what they want. I suppose that’s why there are so many disastrous marriages
  • I had not the heart to laugh at Elliott any more, he seemed to me a profoundly pathetic object. Society was what he lived for, a party was the breath of his nostrils, not to be asked to one was an affront, to be alone was a mortification; and, an old man now, he was desperately afraid. It made me sad to think how silly, useless and trivial his life had been. It mattered very little now that he had gone to so many parties and had hobnobbed with all those princes, dukes, and counts. They have forgotten him already.
  • Art is triumphant when it can use convention as an instrument of its own purpose
  • Advaita doesn’t ask you to take anything on trust; it asks only that you should have a passionate craving to know Reality. It states that you can experience God as surely as you can experience joy or pain.
  • In later ages the sages of India in recognition of human infirmity admitted that salvation may be won by the way of love and the way of works, but they never denied that the noblest way, though the hardest, is the way of knowledge, for its instrument is the most precious faculty of man, his reason
  • We are all greater than we know and the wisdom is the means to freedom. For Salvation, it is not essential to retire from the world , but only renounce the self. Work done with no selfish interest purifies the mind and that duties are opportunities afforded to man to sink his separate self and become one with the universal self.


Austin Kleon’s book is essentially a blog post turned in to a book .The basic theme of the book is that in art as in other forms, you have to steal. The word steal has a negative connotation and hence the book differentiates between two kinds of thefts:


Basically theft in this sense means that you are free from the burden of trying to be completely original. Most of the book is common sense stuff but how often do we really follow commonsense ? 

There are some nice visuals in the book. Some of them that I found interesting are :


Very often, ONLY when you have multiple ideas,
that you are capable of coming up with a perfect idea that works



It is better to separate your workspace in to analog and digital mode

Paul Graham in one of his essays says that he follows a similar configuration where he uses two computers, one connected to internet and the other offline, so that while working on something that requires concentration, the urge to browse randomly, check email, tweets, blogs is eliminated.



As Steve Jobs says, you cannot connect dots going forward.
However, dots you create in fact make you what you are.



All you need is a little space and a little time—a place to work, and some time to do it;
a little self-imposed solitude and temporary captivity.


“Be regular and orderly in your life, so that you may be violent and original in your work.”

— Gustave Flaubert


For any number crunching work, be it making a report or developing a model or doing data diagnostics, visualization of the data is imperative. Be it univariate or multivariate data, visuals help us to look beyond the summary statistics or test statistics. For someone working in finance, there is an entire discipline of `Technical Trading’ where buy , sell , stop-loss decisions are made based on visuals. Whether one believes it or not is a different question altogether. Keeping Technical analysis side, there is an obvious need to look at data, be it histograms, density plots, contour plots, barplots, boxplots, etc. Tools that churn out these graphics are compulsory in any data analyst’s toolbox. My toolbox contains ggplot2, lattice and base-R. I had started using ggplot2 package, 4 years ago, and since then I have been using it regularly in my work. Since the output is usually publication ready, one of the real life situations where I had used ggplot2 visuals was in an annual newsletter to investors that reported their portfolio performance. I don’t think anybody cared about what the visuals were saying as long as the portfolio was making money. But using ggplot2 definitely lent a professional look to the newsletter.

Well the quality of output was certainly one of the motivations behind learning and using ggplot2. However there was a bigger reason that I got attracted towards ggplot2. ggplot2 is not merely something that is helpful in drawing some visuals. It is much more than that. It has an underlying grammar based on Wilkinson’s Grammar of Graphics. Once you take an effort to understand the layered model, you look at a graph from a completely different viewpoint. When I encountered ggplot2, I was totally thrilled because it taught me how to map data to a visual. I can safely say that the grammar model gave me new eyes to look at a visual. Before using ggplot2, I really had a very cursory understanding of statistical graphics. Anyways, I will try to write a separate post on ggplot2 at a later date.

This post is about Matplotlib. I have started liking Python for data analysis. However I have realized that my toolkit was empty for doing visualization in Python. Any book that I start reading on data munging , data cleaning using Python modules, I could not move past a few chapters as there was always a reference to Matplotlib. There was no other option but to slog through Matplotlib and understand the details. I am coming to Matplotlib after working with ggplot2. So learning Matplotlib was an interesting experience where I constantly asked questions like, “How does ggplot2 do the samething ?” “Is the graphing capability for this particular problem better supported in Matplotlib or ggplot2” etc. This kind of constant comparison with ggplot2 and base-R packages helped me understand Matplotlib better.

In this post, I will try to summarize only 50 percent of the book and there’s a reason for it. The first 4 chapter and the last chapter are most relevant for an analyst doing interactive data analysis. There are four other chapters dedicated to embedding Matplotlib in GUI libraries like GTK+ , Qt 4, wxWidgets and the web interfaces. These are more specialized tasks that I don’t think I will be doing in the near future. For a number cruncher like me, the ability to quickly map data to visuals in an interactive manner is the key to doing a good job. Keeping that requirement in mind, I have read only five chapters from this book and have ignored four chapters that deal with embedding Matplotlib. So, in a sense, this summary is a partial summary of the book. Let me try to summarize these five chapters:

Introduction to Matplotlib

Firstly, what’s Matplotlib ? It is a python package for 2D plotting that generates production-quality graphs. It supports interactive and non-interactive plotting, and can save images in several outputs. It can use multiple window toolkits and provides a wide variety of plot types. But the biggest USP in my opinion is the ease of use. Who’s the lead developer for Matplotlib? It is written and maintained primarily by John Hunter.


John Hunter started off Matplotlib as a result of patch rejection from iPython. It was modeled on MATLAB because graphing was something that MATLAB did very well. The high degree of compatibility between them made many people move from MATLAB to Matplotlib. The current version that is available for download is Matplotlib1.1.0. To get an idea in to the massive effort that has gone in to this library, have a look at some of the statistics of Matplotlib 0.8480 that were made in presentation by John Hunter.

There are

  • 80 python modules
  • 21 files of extension
  • 110,000 lines of code
  • 189 examples
  • 2-5 active developers at any time
  • 25 contributors
  • 5000 downloads/month
  • 500 mailing list subscribers
  • 18 backends

These numbers are as of 2006. You might have to extrapolate this data 6 years to get an idea of the massive open source visualization package is out there NOW. No wonder it is used in almost all scientific disciplines.

The book starts off by mentioning the key advantages of Matplotlib

  • It uses Python.
  • Its open source
  • Its a real programming language
  • It is very customizable and extensible
  • It has LaTeX support
  • Its cross platform and portable

Matplotlib gives output in both forms, raster images and vector images. There are two types of backends, Hardcopy backends (output is raster /vector images) and user interface backends. A backend that displays the image on screen is called a user interface backend. Matplotlib introduces two layers , renderer, that does the drawing and canvas , the destination of the drawing. The standard renderer is the Anti-Grain Geometry (AGG) library, a high performance rendering engine which is able to create images of publication level quality, with anti-aliasing, and subpixel accuracy. AGG is responsible for the beautiful appearance of Matplotlib graphs. The canvas is provided with the GUI libraries, and any of them can use the AGG rendering, along with the support for other rendering engines. So to get going, one needs to install NumPy, the Python bindings for the UI you are going to work with, python-dateutil module, pytz – the timezone module. One doesn’t have to worry about all these dependencies if iPython is being used. iPython already has a Matplotlib mode in it. For most of the research purposes, I guess iPython pylab mode is enough to get going. The chapter ends with brief instructions on installing Matplotlib on various platforms.

Getting Started with Matplotlib

This section takes the reader through simple line plots. Through “This-is-the-code-and-this-is-the-output” kind of instruction, the chapter takes the reader through a series of steps , by the end of which, he/she is equipped to draw line plots in python, change the axis labels, reset the axis ranges, add title and legend to the graph and save the plots. The advantage of working with iPython is that whatever changes you make to the figure, they appear instantly on the figure ( sometimes by invoking draw() function). This is a massive advantage because most GUI libraries need to control the main loop of execution of Python, thus preventing any further interaction, i.e you can’t type while viewing the image. The only GUI that plays nice with Python’s shell is Tkinter. iPython in pylab mode starts two threads, one to execute the GUI library code and another thread to handle user command input and hence is so much more useful for a newbie. In fact I found iPython to be tremendously useful while learning NumPy and other packages as it gives instantaneous feedback on what you type. The chapter ends with some explanation to change the default Matplotlib settings. Now this is similar to par() settings in R. Till date, except for a few things I have never really changed them in R. Depending on the graph, I tend to change them in the graphing function itself. From that experience in R and extrapolating it to Matplotlib, I don’t think I will ever change the default settings and meddle with the configuration files.

Decorate Graphs with Plot Styles and Types

For any plot, there is an obvious need to customize stuff. In Matplotlib , the syntax for customization is very simple. If you have to change the color, linestyle and marker style, you can basically change it using just one addition string input to the plot function. Handling xaxis ticks and yaxis ticks also has an intuitive syntax.

There is an interesting pic in the chapter that summarizes the various readily available plots available in Matplotlib


The chapter then goes on to explain the code fragments for generating histograms, pie diagrams,error bar charts, bar charts,scatter plots, polar charts. There is also section on ways to annotate the visual. Overall a very hands on chapter that gives one good enough functions to plot data.

Advanced Matplotlib

This is the really interesting chapter of the book as it explains the OOPS behind Matplotlib. The first three chapters seem almost magical with all plots coming out of Matplotlib blackbox by typing in a few commands. This chapter goes in to the blackbox, explains the OOPS structure in detail. This sort of introduction is invaluable for a newbie Matplotlibber as it equips one with a decent understanding of the various classes and subclasses. This understanding can then be used to go over the documentation of Matplotlib which, by the way, is close to 1100 pages long. Books like these are like the life jackets in the ocean of functions and objects in massive libraries like Matplotlib. I started off with Matplotlib document and it was overwhelming to say the least. This book gave me confidence to go over Matplotlib documentation , not the entire 1100 pages but the most prominent sections of it.

Matplotlib can be used in three ways

  • pyplot : pyplot provides a MATLAB-style, procedural, state-machine interface to the underlying object-oriented library in Matplotlib.Matplotlib.pyplot is stateful because the underlying engine keeps track of the current figure and plotting area information, and plotting functions change that information. No need to use any object references while plotting
  • pylab – a module that merges NumPy and Matplotlib in to one common namespace so that it gives an environment closer to MATLAB
  • OOPS way – This is the most powerful way to write Matplotlib code because it allows for complete control of the result however it is also the most complex. This is the Pythonic way to use Matplotlib, and it’s highly encouraged when programming with Matplotlib rather than working interactively.

The chapter then shows a sample graphic using the first  two ways, pyplot and pylab. It subsequently introduces the basic objects in Matplotlib that gives one the control on the plot, i.e , Figure Canvas, Figure and Axes. The flow of objects is as follows : You start off with a figure object, add subplots to it and work with Axes objects. Once you have figure object and axes objects , you can invoke ton of functions and customize the look and feel . You have much more control over the graphic like setting the scale of the axis, sharing axes etc. The chapter has an important section on dates. This is very useful for plotting financial data. By using locators and formatters, the section shows various ways to show a time series graphic with legible date formats on the x axis. Another interesting things about Matplotlib is the use of LaTeX annotation. Matplotlib includes an internal engine to render expression, mathtext. The mathtext module provides style mathematical expressions using FreeType 2 and the default font from , Computer Modern. As Matplotlib ships with everything it needs to make mathtext work, there is no requirement to install a system.

The chapter ends with contour plots. Ideally this should have appeared in chapter 3 along with other plots. Clubbing it with OOPS concepts makes it a little out of place. In any case, the contour plots are highly useful. As an example, lets say you do a singular value decomposition of a matrix. Linear algebra tells us the resulting matrices form an orthogonal basis. Now you can use contour plots to check that. Lets say I simulate a 20 by 20 random matrix, do an svd and get the u and v matrices. If I take a dot product of u and u transpose , get a 2d matrix, plot the 2d matrix as a contour plot, you get the following visual


All the 1 are on the diagonal and the rest of matrices are populated with 0 values. This tells us that u forms an orthonormal basis.This kind of visualization of matrices is just one of the many things that one can do using Matplotlib

Matplotlib in Real World

This is an interesting chapter of the book that gives a half-a-dozen real life case studies where Matplotlib is used as an effective visualization tool.

After going through this book on Matplotlib I think I have to work with this library and see where it stands with respect to ggplot2. For univariate data, Matplotlib looks like it has the same power as ggplot2 but what about multivariate data. For example, I have used a sample dataset(diamonds) to plot a histogram of one of the data variables using ggplot2 and Matplotlib

Here are the result of Matplotlib and ggplot2(enables to slice based on a different dimension)







Can one replicate the ggplot2 graphic in Matplotlib ? No idea. Need to figure out whether Matplotlib supports faceting and aesthetic grammar layers like ggplot2. But I guess even if Matplotlib does not support grammer of graphics , I think it is worthwhile to learn it as it becomes an invaluable tool , in doing interactive data analysis in python environment.


This book is an accessible introduction to Matplotlib that  equips a reader enough familiarity so that he/she can go over the mammoth 1100 page documentation of Matplotlib.