Python中的 Matplotlib.axes.Axes.get_frame_on()
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。 Axes 类包含大部分图形元素:Axis、Tick、Line2D、Text、Polygon 等,并设置坐标系。 Axes 的实例通过回调属性支持回调。
matplotlib.axes.Axes.get_frame_on()函数
matplotlib 库的 axes 模块中的Axes.get_frame_on()函数用于获取是否绘制了坐标区矩形补丁。
Syntax: Axes.get_frame_on(self)
Parameters: This method does not accept any parameters.
Returns:This method returns whether the axes rectangle patch is drawn or not.
下面的示例说明了 matplotlib.axes 中的 matplotlib.axes.Axes.get_frame_on()函数:
示例 1:
# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-5, 5, 0.01)
y1 = -3 * x*x + 10 * x + 10
y2 = 3 * x*x + x
fig, ax = plt.subplots()
ax.plot(x, y1, x, y2, color ='black')
ax.fill_between(x, y1, y2, where = y2 >y1,
facecolor ='green', alpha = 0.8)
ax.fill_between(x, y1, y2, where = y2 <= y1,
facecolor ='black', alpha = 0.8)
ax.set_frame_on(False)
x = ax.get_frame_on()
ax.text(-2, 80, "Value of set_frame_on : " +str(x),
style ='italic', fontsize = 10, color ="green")
ax.set_title('matplotlib.axes.Axes.get_frame_on()\
Example\n', fontsize = 12, fontweight ='bold')
plt.show()
输出:
示例 2:
# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(16)
y = np.sin(x / 3)
fig, ax = plt.subplots()
ax.step(x, y + 2, label ='pre (default)')
ax.plot(x, y + 2, 'o--', color ='black', alpha = 0.3)
ax.step(x, y + 1, where ='mid', label ='mid')
ax.plot(x, y + 1, 'o--', color ='black', alpha = 0.3)
ax.step(x, y, where ='post', label ='post')
ax.plot(x, y, 'o--', color ='black', alpha = 0.3)
ax.grid(axis ='x', color ='0.95')
x = ax.get_frame_on()
ax.text(4, 3.2, "Rectangulr Patch is Drawn : " +str(x),
style ='italic', fontsize = 10, color ="green")
ax.set_title('matplotlib.axes.Axes.get_frame_on()\
Example\n', fontsize = 12, fontweight ='bold')
plt.show()
输出: