Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
matplotlib Plotting Cookbook

You're reading from   matplotlib Plotting Cookbook Discover how easy it can be to create great scientific visualizations with Python. This cookbook includes over sixty matplotlib recipes together with clarifying explanations to ensure you can produce plots of high quality.

Arrow left icon
Product type Paperback
Published in Mar 2014
Publisher Packt
ISBN-13 9781849513265
Length 222 pages
Edition Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Alexandre Devert Alexandre Devert
Author Profile Icon Alexandre Devert
Alexandre Devert
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

matplotlib Plotting Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. First Steps FREE CHAPTER 2. Customizing the Color and Styles 3. Working with Annotations 4. Working with Figures 5. Working with a File Output 6. Working with Maps 7. Working with 3D Figures 8. User Interface Index

Installing matplotlib


Before experimenting with matplotlib, you need to install it. Here we introduce some tips to get matplotlib up and running without too much trouble.

How to do it...

We have three likely scenarios: you might be using Linux, OS X, or Windows.

Linux

Most Linux distributions have Python installed by default, and provide matplotlib in their standard package list. So all you have to do is use the package manager of your distribution to install matplotlib automatically. In addition to matplotlib, we highly recommend that you install NumPy, SciPy, and SymPy, as they are supposed to work together. The following list consists of commands to enable the default packages available in different versions of Linux:

  • Ubuntu: The default Python packages are compiled for Python 2.7. In a command terminal, enter the following command:

    sudo apt-get install python-matplotlib python-numpy python-scipy python-sympy
    
  • ArchLinux: The default Python packages are compiled for Python 3. In a command terminal, enter the following command:

    sudo pacman -S python-matplotlib python-numpy python-scipy python-sympy
    

    If you prefer using Python 2.7, replace python by python2 in the package names

  • Fedora: The default Python packages are compiled for Python 2.7. In a command terminal, enter the following command:

    sudo yum install python-matplotlib numpy scipy sympy
    

    Note

    There are other ways to install these packages; in this chapter, we propose the most simple and seamless ways to do it.

Windows and OS X

Windows and OS X do not have a standard package system for software installation. We have two options—using a ready-made self-installing package or compiling matplotlib from the code source. The second option involves much more work; it is worth the effort to have the latest, bleeding edge version of matplotlib installed. Therefore, in most cases, using a ready-made package is a more pragmatic choice.

You have several choices for ready-made packages: Anaconda, Enthought Canopy, Algorete Loopy, and more! All these packages provide Python, SciPy, NumPy, matplotlib, and more (a text editor and fancy interactive shells) in one go. Indeed, all these systems install their own package manager and from there you install/uninstall additional packages as you would do on a typical Linux distribution. For the sake of brevity, we will provide instructions only for Enthought Canopy. All the other systems have extensive documentation online, so installing them should not be too much of a problem.

So, let's install Enthought Canopy by performing the following steps:

  1. Download the Enthought Canopy installer from https://www.enthought.com/products/canopy. You can choose the free Express edition. The website can guess your operating system and propose the right installer for you.

  2. Run the Enthought Canopy installer. You do not need to be an administrator to install the package if you do not want to share the installed software with other users.

  3. When installing, just click on Next to keep the defaults. You can find additional information about the installation process at http://docs.enthought.com/canopy/quick-start.html.

That's it! You will have Python 2.7, NumPy, SciPy, and matplotlib installed and ready to run.

You have been reading a chapter from
matplotlib Plotting Cookbook
Published in: Mar 2014
Publisher: Packt
ISBN-13: 9781849513265
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image