How to use matplotlib under Windows

Source: Internet
Author: User
Tags install matplotlib

Before beginning, to the creator of Matplotlib, John D. Hunter, to express a high respect, and endless nostalgia.

(John D. Hunter 1968-2012)

Matplotlib is a drawing library that gives Python a very beautiful look.

Install Python

First, installing the python2.7,3.x version of Python is not as stable as 2.X in the development process. So we use the python2.7 version. And many Python versions are based on 32-bit, so we choose the 32-bit version of 2.7.X to install. 32-bit 2.7.X version was found from https://www.python.org/downloads/for installation. Add environment variables, "c:\python27;c:\python27\scripts;" The path is where Python is installed.

After the addition, go to CMD and run the "Python" command if it appears

It means success (bad, exposing the blogger!) )

Write a Python program

Running a python file is simple, in two ways, the first is using a Python-provided GUI interface (the IDLE python gui),

This shell can provide you with a lot of help, such as helping and so on. As you can see, I installed the python2.7.9,32 bit version.

The second way, is more netizens to provide Eclipse+pydev way, eclipse everyone is not unfamiliar, Pydev is a plug-in eclipse. However, Eclipse will not be able to download the older version, and the blogger Eclipse Luna 4.4 is not very good. Below the Pydev I use to contribute to Http://pan.baidu.com/s/1qWqfk2C. Then my version of Eclipse Link: http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/indigo/ Sr2/eclipse-java-indigo-sr2-win32.zip

The way to install Pydev is simple, copy the feature folder and the plugin folder. Then found in windows->preferences:

Add your Python (need not manually add I forgot ... sorry) but should not be added manually, after all, there is System Pythonpath, guess. Then the Python program is ready to run!

Finally to the installation of the Matplotlib link!

Open the GUI interface. Input

"Import Matplotlib"

Wow! is not an error!

We're going to put a thing called numpy. HTTP://SOURCEFORGE.NET/PROJECTS/NUMPY/FILES/NUMPY/1.9.1/Be sure to watch the Python version before downloading! Fool installation method.

Again install Matplotlib, still lose that code, is not again error?

We're going to install matplotlib. Http://matplotlib.org/downloads.html find the right version Oh!

Re-lose code, Oshit and error!? Does that mean "Six" is missing?

https://pypi.python.org/pypi/six/download the. tar.gz version and copy the extracted version to the Python folder.

Again lost code, crouching slot and error, missing "Dateutil" right?

http://www.lfd.uci.edu/~gohlke/pythonlibs/#

Look up from above, or that sentence, see the version Oh!

Lose code again, I rub or wrong ... Missing pyparsing, right? In the above URL also have, download and install, find the right version.

Oak! It's not wrong again!

Make such a piece of code, online copy.

import NumPy as Npimport matplotlib.pyplot as plt N =5Menmeans = ( -, *, -, *, -) menstd = (2,3,4,1,2) ind = Np.arange (N) # The X locations for the groupswidth =0. *# The width of the bars fig, ax = plt.subplots () rects1 = Ax.bar (Ind, Menmeans, width, color='R', yerr=menstd) Womenmeans = ( -, +, the, -, -) womenstd = (3,5,2,3,3) rects2 = Ax.bar (Ind+width, Womenmeans, width, color='y', YERR=WOMENSTD) #AddSomeax.set_ylabel ('Scores') Ax.set_title ('Scores by group and gender') ax.set_xticks (ind+width) ax.set_xticklabels ('G1','G2','G3','G4','G5')) Ax.legend (rects1[0], rects2[0]), (' Men','Women') def AutoLabel (rects): # Attach some text labels for rectinch rects:height = rect.get_height () ax.text (rect.get_x () +rect.get_width ()/2.,1. to*height,'%d'%int(height), ha='Center', va='Bottom') AutoLabel (rects1) AutoLabel (rects2) plt.show ()

Run a little bit!

Success!!!

So far, I wish you all the best!

How to use matplotlib under Windows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.