Chapter 9. Plotting with Matplotlib

Matplotlib is a very useful Python plotting library. It integrates nicely with NumPy but is a separate open source project. You can find a gallery of beautiful examples at http://matplotlib.sourceforge.net/gallery.html.

Matplotlib also has utility functions to download and manipulate data from Yahoo Finance. We will see several examples of stock charts.

This chapter features extended coverage of:

  • Simple plots
  • Subplots
  • Histograms
  • Plot customization
  • Three-dimensional plots
  • Contour plots
  • Animation
  • Logplots

Simple plots

The matplotlib.pyplot package contains functionality for simple plots. It is important to remember that each subsequent function call changes the state of the current plot. Eventually we will want to either save the plot in a file or display it with the show function. However, if we are in IPython running on a Qt or Wx backend the figure will be updated interactively without waiting for the show function. This is comparable to the way text output is printed on the fly.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset