Book Image

Python Data Analysis

By : Ivan Idris
Book Image

Python Data Analysis

By: Ivan Idris

Overview of this book

Table of Contents (22 chapters)
Python Data Analysis
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Key Concepts
Online Resources
Index

matplotlib


The following are useful matplotlib functions:

  • matplotlib.pyplot.axis(*v, **kwargs): This is the method to get or set axis properties. For example, axis('off') turns off the axis lines and labels.

  • matplotlib.pyplot.figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True, FigureClass=<class 'matplotlib.figure.Figure'>, **kwargs): This function creates a new figure.

  • matplotlib.pyplot.grid(b=None, which='major', axis='both', **kwargs): This function turns the plot grids on or off.

  • matplotlib.pyplot.hist(x, bins=10, range=None, normed=False, weights=None, cumulative=False, bottom=None, histtype='bar', align='mid', orientation='vertical', rwidth=None, log=False, color=None, label=None, stacked=False, hold=None, **kwargs): This function plots a histogram.

  • matplotlib.pyplot.imshow(X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=None, vmin=None, vmax=None, origin=None, extent=None, shape=None, filternorm=1, filterrad=4.0, imlim=None, resample=None, url=None, hold=None, **kwargs): This function displays an image for array-like data.

  • matplotlib.pyplot.legend(*args, **kwargs): This function shows a legend at an optionally specified location (for instance, plt.legend(loc='best')).

  • matplotlib.pyplot.plot(*args, **kwargs): This function creates a two-dimensional plot with single or multiple (x, y) pairs and a corresponding optional format string.

  • matplotlib.pyplot.scatter(x, y, s=20, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, hold=None, **kwargs): This function creates a scatter plot of two arrays.

  • matplotlib.pyplot.show(*args, **kw): This function displays a plot.

  • matplotlib.pyplot.subplot(*args, **kwargs): This function creates subplots if the row number, column number, and index number of the plot are given. All these numbers start from one. For instance, plt.subplot(221) creates the first subplot in a two-by-two grid.

  • matplotlib.pyplot.title(s, *args, **kwargs): This function puts a title on the plot.