Matplotlib学习(1)Usage Guide使用指南

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

声明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()

运行结果:1

2.Parts of a figure(介绍figure的各部分)

了解一幅figure中的每个part的英文表示
2
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

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值