声明1:此为我的个人学习笔记,转载请附原文链接。
声明2:英语水平扎实的同学学Matplotlib库建议到Matplotlib 3.3.2 documentation
感觉直接读英文文档吃力的我有两个建议:
1.下载浏览器插件,全屏翻译,辅助学习。(但切记不要看着翻译学习!只起辅助理解作用;还有不要深钻单个英文单词的意思,学技术捎带学英语,主次关系要明确!)
2.可以先看我的笔记入了门,然后再参照原文档深入学习或者从实践中学习,需用什么图就学什么。
目录
1.A simple example
The most simple way of creating a figure with an axes is using pyplot.subplots. We can then use Axes.plot to draw some data on the axes:
创建带有轴的图形最简单的方法是使用 pyplot.subplot。然后我们可以使用 Axes.plot 在轴上绘制一些数据:
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots() # Create a figure containing a single axes;axes:坐标轴,axis:坐标轴线
ax.plot([1, 2, 3, 4], [1, 4, 2, 3]) # Plot some data on the axes.
plt.show()
运行结果:
2.Parts of a figure(介绍figure的各部分)
了解一幅figure中的每个part的英文表示

Figure:The whole figure. The figure keeps track of all the child Axes, 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 contain any number of Axes, but will typically have at least one.
我的理解是:Figure就是整个画布,包含轴和一些别的比较特别的Artist(标题,分类图示等),一般来说一个figure至少有一个Axes。
Axes:This is what you think of as ‘a plot’, it is the region of the image with the data space. A given figure can contain many Axes, but a given Axes object can only be in one Figure. The Axes contains two (or three in the case of 3D) Axis objects (be aware of the difference between Axes and Axis) which take care of the data limits (the data limits can also be controlled via the axes.Axes.set_xlim() and axes.Axes.set_ylim() methods). Each Axes has a title (set via set_title()), an x-label (set via set_xlabel()), and a y-label set via set_ylabel()).
我的理解是:Axes就是figure内的一个区域,只不过这个区域不是空白的,是由轴与实现包围的。一个figure可以包含很多axes,但某个给定的axes只能在一个figure中。
Axis:These are the number-line-like objects. They take care of setting the graph limits and generating the ticks (the marks on the axis) and ticklabels (strings labeling the ticks). The location of the ticks

本文是关于Python中Matplotlib库的学习笔记。介绍了创建图形的简单示例,讲解了figure各部分,如Figure、Axes、Axis和Artist的含义。还提及创建新图形的方法、绘图函数输入类型,对比了面向对象和pyplot两种绘图接口,以及写专门绘图函数和后端相关知识。
最低0.47元/天 解锁文章
7676

被折叠的 条评论
为什么被折叠?



