matplotlib python高级绘图库 一周总结

matplotlib python高级绘图库 一周总结

官网 http://matplotlib.org/

是一个python科学作图库,可以快速的生成很多非常专业的图表。

只要你掌握要领,画图将变得非常方便(不能说非常简单,只能说非常方便,

科学绘图确实很复杂,需要较久时间熟悉)。

后续简称 mpl 库。

既然是作图,那么图里面总有坐标系,绘图画板,坐标轴等概念和操作方式。

mpl都提供了具体的类来对应。

总结一周以来的学习心得(仅生成过2D坐标,就不讨论3D和立体图等)。

http://matplotlib.org/faq/usage_faq.html#general-concepts

提供了基本概念描述:

General Concepts

matplotlib has an extensive codebase that can be daunting to many new users. However, most of matplotlib can be understood with a fairly simple conceptual framework and knowledge of a few important points.

mpl 代码库比较肥,新用户一般都比较困扰(学霸除外)。

但可以从一个一致的逻辑架构和几个关键知识点入手来理清mpl库。

Plotting requires action on a range of levels, from the most general (e.g., ‘contour this 2-D array’) to the most specific (e.g., ‘color this screen pixel red’). The purpose of a plotting package is to assist you in visualizing your data as easily as possible, with all the necessary control – that is, by using relatively high-level commands most of the time, and still have the ability to use the low-level commands when needed.

制图,总共是几种层次的绘图指令(比如,最常见的绘制某2维数组图 或 将此屏幕的像素渲染成红色)。

mpl当然就是在你把数据转换成可视图像中提供尽量多的方便,但又不失掉细节控制力---这些都通过提供

相对高层次的各种命令来完成,但更底层具体的命令也是可用的。

Therefore, everything in matplotlib is organized in a hierarchy. At the top of the hierarchy is the matplotlib “state-machine environment” which is provided by the matplotlib.pyplot module. At this level, simple functions are used to add plot elements (lines, images, text, etc.) to the current axes in the current figure.

因此,所有mpl的内容都是以树形逻辑来组织。最顶层,是mpl的“状态机接口环境”,由mpl.pyplot模块提供。

。。。

mpl提供了两个模块来提供两种开发体验。

-   matplotlib.pyplot
-   matplotlib.pylab

下面是各种名词概念。

Figure

所有mpl的图都是绘制在Figure上的某处,figure是所有东西的总管。

Axes

坐标系,一个Figure可能会有多个Axes。

Axis

2D坐标系的某坐标轴,上面的Axes是复数性质,即Axes是坐标系,Axis是x或者y坐标。

Artist

mpl各种图像实体的父类。

某实体,包括Axes、Axis,Ticker,Locator等都是Artist的子类。

未完待续。