matplotlib.pyplot.axis()与matplotlib.pyplot.axes()结构及用法
-
matplotlib.pyplot.axis() 官方文档
matplotlib.pyplot.axis(*v, **kwargs)
获得或设定axis内容的便利方法。
常用参数:
xmin, ymin, xmax, ymax : float, optional
The axis limits to be set. Either none or all of the limits must be given.
option : str
Possible values:
Value | Description |
---|---|
‘on’ | Turn on axis lines and labels. |
‘off’ | Turn off axis lines and labels. |
‘equal’ | Set equal scaling (i.e., make circles circular) by changing axis limits. |
‘scaled’ | Set equal scaling (i.e., make circles circular) by changing dimensions of the plot box. |
‘tight’ | Set limits just large enough to show all data. |
‘auto’ | Automatic scaling (fill plot box with data). |
‘normal’ | Same as ‘auto’; deprecated. |
‘image’ | ‘scaled’ with axis limits equal to data limits. |
‘square’ | Square plot; similar to ‘scaled’, but initially forcing xmax-xmin = ymax-ymin . |
emit : bool, optional, default True
Whether observers are notified of the axis limit change. This option is passed on to set_xlim
andset_ylim
.
-
matplotlib.pyplot.axes() 官方文档
matplotlib.pyplot.axes(arg=None, **kwargs)
在当前figure新增一个axes对象,并设为当前活动。
axes不是数学上的座标轴,而是图形结构中的一个对象。所有绘图函数都是直接作用在当前axes对象上。
# 示例
plt.axes()
plt.axes(rect, projection=None, polar=False, **kwargs)
plt.axes(ax)
常用参数:
arg : { None, 4-tuple, Axes }
The exact behavior of this function depends on the type:
-
None: A new full window axes is added using
subplot(111, **kwargs)
-
4-tuple of floats rect =
[left, bottom, width, height]
. A new axes is added with dimensions rect in normalized (0, 1) units usingadd_axes
on the current figure. -
Axes
: This is equivalent topyplot.sca
. It sets the current axes to arg. Note: This implicitly changes the current figure to the parent of arg.Note
projection : {None, ‘aitoff’, ‘hammer’, ‘lambert’, ‘mollweide’, ‘polar’, ‘rectilinear’, str}, optional
The projection type of the Axes
. str is the name of a costum projection, see projections
. The default None results in a ‘rectilinear’ projection.
polar : boolean, optional
If True, equivalent to projection=‘polar’.
sharex, sharey : Axes
, optional
Share the x or y axis
with sharex and/or sharey. The axis will have the same limits, ticks, and scale as the axis of the shared axes.
label : str
A label for the returned axes.