Home Backend Development Python Tutorial python绘图库Matplotlib的安装

python绘图库Matplotlib的安装

Jun 06, 2016 am 11:30 AM
matplotlib python Install Drawing

本文简单介绍了Python绘图库Matplotlib的安装,简介如下:

matplotlib是python最著名的绘图库,它提供了一整套和matlab相似的命令API,十分适合交互式地
进行制图。Matplotlib的安装可以参见:官网链接 http://matplotlib.org/users/installing.html

安装总结步骤如下:

windows 平台上下载.exe格式 直接安装。

1.python下载安装 下载地址:http://www.python.org/download/。
2.安装你所需要版本(这个要根据步骤1的python版本)的Matplotlib,下载地址:http://matplotlib.org/downloads.html。
下面安装Matplotlib 依赖的库
3.对于标准版的Python来说,要使用Matplotlib,还需要安装numpy模块,其下载地址为:http://sourceforge.net/projects/numpy/files/NumPy/。
4.msvcp71.dll, 在某些系统上,你可能还需要下载msvcp71.dll库。下载地址:http://www.dll-files.com/dllindex/dll-files.shtml?msvcp71
     下载解压后把它拖到c:\windows\system32目录中。
5.运行一个简单的程序例子:
 
view plaincopy在CODE上查看代码片派生到我的代码片

import matplotlib.pyplot as plt 
plt.plot([1,2,3]) 
plt.ylabel('some numbers') 
plt.show()
Copy after login

安装过程遇到的错误
发现出现了下面的错误:
raise ImportError("matplotlib requires dateutil")
ImportError: matplotlib requires dateutil
这个需要dateutil,你可以到这里下载安装:http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-dateutil。

把dateutil 安装完后又出现如下错误:
raise ImportError("matplotlib requires pyparsing")
ImportError: matplotlib requires pyparsing
需要 pyparsing 到这里下载安装:http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyparsing。

完成以上步骤,运行上面的例子就可以显示我们的图像,如下所示。

在程序安装过程中如果遇到需要安装的一些依赖包,你可以到这里查找http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyparsing,这确实是个好资源。

可以根据所画图形的需要 在下面的链接里选择相应的图形 进行修改,绘出自己所需的图像。
example: http://matplotlib.org/examples/index.html, gallery:http://matplotlib.org/gallery.html
相关资源链接:
Matplotlib Tutorial 中文翻译的 http://reverland.org/python/2012/09/07/matplotlib-tutorial/ 。
用Python做科学计算 http://sebug.net/paper/books/scipydoc/index.html 。

资源下载:
如果上面不能下载。我把安装 python matplotlib所需的软件放到百度网盘了,可以到这里这下:http://pan.baidu.com/s/1i3C99rv。

中文乱码解决方法

注意绘图时中文的解决方法, 在.py文件头部加上如下内容:

# -*- coding: utf-8 -*- 
from pylab import * 
mpl.rcParams['font.sans-serif'] = ['SimHei'] #指定默认字体 
mpl.rcParams['axes.unicode_minus'] = False #解决保存图像是负号'-'显示为方块的问题
Copy after login

绘图脚本.py转为 .exe

 如果为希望能把Python脚本发布为脱离Python平台运行的可执行程序,比如单个的exe文件。可以参考这篇博文:http://blog.csdn.net/daniel_ustc/article/details/15501385

使用便携式的Python环境

Python 编程语言在移动设备下的运行环境和编程语言环境,便携式的Python是一个Python的编程语言预先从任何USB存储设备直接运行,使在任何时候,你有一台便携式的编程环境。使其起来挺方便的,推荐使用。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to convert XML files to PDF on your phone? How to convert XML files to PDF on your phone? Apr 02, 2025 pm 10:12 PM

It is impossible to complete XML to PDF conversion directly on your phone with a single application. It is necessary to use cloud services, which can be achieved through two steps: 1. Convert XML to PDF in the cloud, 2. Access or download the converted PDF file on the mobile phone.

What is the function of C language sum? What is the function of C language sum? Apr 03, 2025 pm 02:21 PM

There is no built-in sum function in C language, so it needs to be written by yourself. Sum can be achieved by traversing the array and accumulating elements: Loop version: Sum is calculated using for loop and array length. Pointer version: Use pointers to point to array elements, and efficient summing is achieved through self-increment pointers. Dynamically allocate array version: Dynamically allocate arrays and manage memory yourself, ensuring that allocated memory is freed to prevent memory leaks.

How to convert XML to PDF on your phone? How to convert XML to PDF on your phone? Apr 02, 2025 pm 10:18 PM

It is not easy to convert XML to PDF directly on your phone, but it can be achieved with the help of cloud services. It is recommended to use a lightweight mobile app to upload XML files and receive generated PDFs, and convert them with cloud APIs. Cloud APIs use serverless computing services, and choosing the right platform is crucial. Complexity, error handling, security, and optimization strategies need to be considered when handling XML parsing and PDF generation. The entire process requires the front-end app and the back-end API to work together, and it requires some understanding of a variety of technologies.

How to convert xml into pictures How to convert xml into pictures Apr 03, 2025 am 07:39 AM

XML can be converted to images by using an XSLT converter or image library. XSLT Converter: Use an XSLT processor and stylesheet to convert XML to images. Image Library: Use libraries such as PIL or ImageMagick to create images from XML data, such as drawing shapes and text.

Who gets paid more Python or JavaScript? Who gets paid more Python or JavaScript? Apr 04, 2025 am 12:09 AM

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.

How to convert xml to mp3 How to convert xml to mp3 Apr 03, 2025 am 09:00 AM

The steps to convert XML to MP3 include: Extract audio data from XML: parse the XML file, find the base64 encoding string containing the audio data, and decode it into binary format. Encode the audio data to MP3: Install the MP3 encoder and set the encoding parameters, encode the binary audio data to MP3 format, and save it to a file.

How to change the format of xml How to change the format of xml Apr 03, 2025 am 08:42 AM

There are several ways to modify XML formats: manually editing with a text editor such as Notepad; automatically formatting with online or desktop XML formatting tools such as XMLbeautifier; define conversion rules using XML conversion tools such as XSLT; or parse and operate using programming languages ​​such as Python. Be careful when modifying and back up the original files.

Is distinctIdistinguish related? Is distinctIdistinguish related? Apr 03, 2025 pm 10:30 PM

Although distinct and distinct are related to distinction, they are used differently: distinct (adjective) describes the uniqueness of things themselves and is used to emphasize differences between things; distinct (verb) represents the distinction behavior or ability, and is used to describe the discrimination process. In programming, distinct is often used to represent the uniqueness of elements in a collection, such as deduplication operations; distinct is reflected in the design of algorithms or functions, such as distinguishing odd and even numbers. When optimizing, the distinct operation should select the appropriate algorithm and data structure, while the distinct operation should optimize the distinction between logical efficiency and pay attention to writing clear and readable code.

See all articles