科学绘图

常规的绘图软件如tecplot,matlab等,对于这些软件,友好的用户界面使新手们可以快速上手。但如果需要定制复杂的图像,依然要花一番功夫。

为什么选择python,因为python作为胶水语言,几乎能实现绝大多数开发要求的需要。

本文主要基于matplotlib官方的用户文档和部分应用进行整理。

Usage Guide | Matplotlib 中文

Matplotlib 简介

matplotlib是非常好用的绘图第三方库,可以简单的画出各种图像。

最基本的一个概念是它的架构理论,matplotlib的结构是一层一层逐级递进的,它的最顶层结构是matplotlib.pyplot这个模块。

因此只需要调动这个模块就可以轻松实现当前图像绘图元素(线,图,文本等)的基础应用。

matplotlib的User Guide中,是这样描述的:

Pyplot's state-machine environment behaves similarly to MATLAB and should be most familiar to users with MATLAB experience. (可见matplotlib是和matlab高度相似的)

安装

Installing | Matplotlib 中文

图表元素

anatomy.png

图表的构成(注意图中的英文):

Figure

The whole figure. The figure keeps track of all the child Axes (opens new window), a smattering of 'special' artists (titles, figure legends, etc), and the canvas. (Don't worry too much about the canvas, it is crucial as it is the object that actually does the drawing to get you your plot, but as the user it is more-or-less invisible to you). A figure can have any number of Axes (opens new window), but to be useful should have at least one.

Axes