Don't get confused between axes and axis. Axis is an element of axes. Grammatically, axes is also the plural for axis, so interpret the meaning of axes depending on the context, whether multiple axis elements are being referred to or an axes object is being referred to.
plt.title("Interactive Plot")#Prints the title on top of graph
plt.xlabel("X-axis")# Prints X axis label as "X-axis"
plt.ylabel("Y-axis")# Prints Y axis label as "Y-axis"
...
...
@@ -139,7 +139,7 @@ plt.ylabel("Y-axis") # Prints Y axis label as "Y-axis"
![](img/94d8d70a-cdaf-481e-bdce-b614c54b7de5.png)
# 工作原理
## 工作原理
因此,这就是解释的方式:
...
...
@@ -161,7 +161,7 @@ plt.ylabel("Y-axis") # Prints Y axis label as "Y-axis"
In older versions of Matplotlib or certain backends (such as `macosx`), the graph may not be updated immediately. In such cases, you need to call `plt.draw()` explicitly at the end, so that the graph gets displayed.
![](img/d402e05e-7f6a-4ede-8d2a-af1d38568344.png) The latest versions of Jupyter Notebook seem to display the figure without calling `plt.show()` command explicitly. However, in Python shell or embedded applications, `plt.show()` or `plt.draw()` is required to display the figure on the screen.
It should be noted that these values will be active for all plots in the session. If you want different settings for each plot in the same session, then you should use the attributes available with the `plot` command.
如果我们为第三个图编码了`plt.subplot(211)`,它将覆盖前两个图,因为 211 表示`2 x 1`网格中的第一个图,它将从第一行开始! 如果我们要绘制相同的三个图,但在第一列中排列两个,在第二列中排列一个,而不是第一行中当前的前两个图和第二行中的第三个图,那么我们将不得不指定绘图顺序为 221、223 和 122。 试试看作为练习!
# 更多
## 更多
由于存在许多此类可能的网格,因此我们将再看到一个示例,该示例在`2 x 2`网格中包含四个不同的图,每个图具有不同类型的图形,直方图,折线图,散点图和条形图。 在最后一个示例中,我们一直使用和`plt.subplot()`方法一个接一个地添加轴域。 在此示例中,我们将一次定义网格中的所有轴域,然后使用索引来访问每个轴域并绘制不同的图形:
![](img/c96236d3-cf90-4521-9802-ebcfe7e80fbf.png)Matplotlib supports four different scales. The default is *linear,* and we have covered *log* in this recipe. You can refer to the Matplotlib documentation for the other two scales: [*symlog* and *logit*](https://matplotlib.org/examples/scales/scales.html).
`basic_units.py` is not a standard package to be installed like all other Python packages. It is a user-defined Python program that needs to be copied into your working directory. Then, in the main program, import the functions from this program similar to the way we import any other package or user-defined programs.
# 准备
## 准备
将`basic_units.py`复制到工作目录后,即可开始使用那里的所有可用功能。
...
...
@@ -518,7 +518,7 @@ from basic_units import cm, inch
importmatplotlib.pyplotasplt
```
# 操作步骤
## 操作步骤
以下代码块绘制了两个图,一个是厘米,另一个是英寸,以演示两个度量单位之间的差异:
...
...
@@ -583,7 +583,7 @@ plt.tight_layout(pad=3)
plt.show()
```
# 工作原理
## 工作原理
这是代码工作方式的说明:
...
...
@@ -605,7 +605,7 @@ It should be noted that Matplotlib does not support sharing objects across diffe
由于在两个图上的比例都是和相同,因此线条的大小以英寸为单位要比以厘米为单位要小。
# 更多
## 更多
这是在 *x* 和 *y* 轴上使用厘米和英寸的混合的另一个示例。 我们有四个条形图,其中和相同的输入数据绘制在`2 x 2`的网格上。