我注意到矩形和fancyboxpatch对象的绘制方式不一致。我希望下面的代码生成两个几乎相同的正方形。你知道吗
from matplotlib.patches import Rectangle, FancyBboxPatch
import matplotlib.pyplot as plt
f = plt.figure()
ax = f.add_subplot(1,1,1)
bbox1 = Rectangle((0.4, 0.4), .1, .1,
transform=ax.transData, ec='red',fill=False)
bbox2 = FancyBboxPatch((0.4, 0.4), .1, .1, boxstyle='square',
transform=ax.transData, ec='green',fill=False)
ax.add_patch(bbox1)
ax.add_patch(bbox2)
f.show()
实际结果与预期不符。在交互式窗口中打印时,平移和缩放的效果与使用transData
的对象所预期的一样。似乎FancyBBoxPatch
的初始大小和位置并没有像我期望的那样被设置。你能告诉我我错过了什么吗?
我不知道简单的RTFM的礼节是什么,但是我会贴出答案而不是删除问题。你知道吗
默认情况下,“正方形”样式在框周围的填充为0.3。设置
pad=0
会产生一致的结果。你知道吗相关问题 更多 >
编程相关推荐