Matplotlib是Python中的一个库,它是数字的-NumPy库的数学扩展。轴类包含大多数图形元素:Axis,Tick,Line2D,Text,Polygon等,并设置坐标系。 Axes实例通过callbacks属性支持回调。
matplotlib.axes.Axes.use_sticky_edges()函数
matplotlib库的axiss模块中的Axes.use_sticky_edges()函数用于是否遵循所有Artist.sticky_edges。
用法:
Axes.use_sticky_edges
以下示例说明了matplotlib.axes中的matplotlib.axes.Axes.use_sticky_edges()函数:
范例1:
# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
y, x = np.mgrid[:6, 1:6]
poly_coords = [
(0.25, 2.75), (3.25, 2.75),
(2.25, 0.75), (0.25, 0.75)
]
fig, ax = plt.subplots()
ax.use_sticky_edges = False
ax.pcolor(x, y, y + 20 * x, cmap ='Greens')
ax.margins(x = 0.1, y = 0.05)
ax.set_aspect('equal')
fig.suptitle('matplotlib.axes.Axes.use_sticky_edges() \
function Example\n', fontweight ="bold")
fig.canvas.draw()
plt.show()
输出:
范例2:
# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
y, x = np.mgrid[:6, 1:6]
poly_coords = [
(0.25, 2.75), (3.25, 2.75),
(2.25, 0.75), (0.25, 0.75)
]
fig, (ax1, ax2) = plt.subplots(nrows = 2)
ax2.use_sticky_edges = False
for ax, status in zip((ax1, ax2),
('Is', 'Is Not')):
# sticky
cells = ax.pcolor(x, y, x + y,
cmap ='PuBuGn')
ax.add_patch(
plt.Polygon(poly_coords, color ='green',
alpha = 0.5)
) # not sticky
ax.margins(x = 0.1, y = 0.05)
ax.set_aspect('equal')
ax.set_title('use_sticky_edges() function {} used'.format(status),
fontweight ="bold")
fig.suptitle('matplotlib.axes.Axes.use_sticky_edges() function \
Example\n', fontweight ="bold")
fig.canvas.draw()
plt.show()
输出:
相关用法
注:本文由纯净天空筛选整理自SHUBHAMSINGH10大神的英文原创作品 matplotlib.axes.Axes.use_sticky_edges() in Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。