Python中的 Matplotlib.axes.Axes.axis()
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。 Axes 类包含大部分图形元素:Axis、Tick、Line2D、Text、Polygon 等,并设置坐标系。 Axes 的实例通过回调属性支持回调。
matplotlib.axes.Axes.axis()函数
matplotlib 库的 axes 模块中的Axes.axis()函数是获取或设置某些轴属性的便捷方法。
Syntax: Axes.axis(self, *args, **kwargs)
Parameters: This method accept the following parameters that are described below:
- xmin, xmax, ymin, ymax : These parameter are the axis limits to be set.
- option : This parameter is the used to turns axis lines and labels on or off or the options.
- emit : This parameter is used to check whether the observers are notified of the axis limit change.
Returns:This method returns the following:
- xmin, xmax, ymin, ymax :This returns the axis limits.
下面的示例说明了 matplotlib.axes 中的 matplotlib.axes.Axes.axis()函数:
示例 1:
axis([xmin, xmax, ymin, ymax])
输出:
示例 2:
# Implementation of matplotlib function
import matplotlib.pyplot as plt
import numpy as np
labels = 'Geek1', 'Geek2', 'Geek3', 'Geek4', 'Geek5'
sizes = [95, 230, 145, 40, 65]
explode = (0, 0.2, 0, 0, 0)
fig1, ax1 = plt.subplots()
ax1.pie(sizes, explode = explode, labels = labels,
autopct ='% 1.0f %%',
shadow = True, startangle = 90)
ax1.axis('square')
ax1.set_title('matplotlib.axes.Axes.axis() \
Example\n', fontsize = 14, fontweight ='bold')
plt.show()
输出: