【发布时间】:2019-05-23 06:26:20
【问题描述】:
我在理解如何用补丁剪辑轴时遇到了一些麻烦。我想让蓝色矩形位于轴的背景中。但是我的剪辑调用什么也没做。
import matplotlib.pyplot as plt
from matplotlib import patches
import numpy as np
fig = plt.figure()
X, Y = np.mgrid[-1:1:.1, -1:1:.1]
Z = X+Y
ax1 = fig.add_subplot(111)
ax1.contourf(X, Y, Z)
frame = patches.Rectangle(
(-.1,-.1), 1.2, 1.2, transform=ax1.transAxes, alpha=.5, fc='b', fill=True, linewidth=3, color='k'
)
ax1.set_clip_path(frame) # has no effect
fig.patches.append(frame)
fig.show()
我需要如何正确设置?文档非常缺乏。
【问题讨论】:
标签: python matplotlib clipping