在下面的示例中,我使用matplotlib.patches.Polygon. 在将补丁添加到绘图之前,有没有办法缩放补丁?在
我试过用matplotlib.transforms.Affine2D以各种各样的方式都没有成功。与往常一样,关于转换的matplotlib文档是远远不够的。在
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
fig = plt.figure()
ax = fig.add_subplot(111)
plt.plot([-3,3],[-3,3])
x = [-1,0,1,1,0,-1]
y = [1,1,1,-1,-1,-1]
poly = Polygon( zip(x,y), facecolor='red', edgecolor='red', alpha=0.5)
ax.add_patch(poly)
plt.show()
如果你所说的比例是乘以一个因子,你可以很容易地通过numpy来实现。在
同样可以通过
^{pr2}$matplotlib.transforms.Affine2D()
转换实现。在尽管对于这样简单的缩放来说,这似乎有点过头了。在
相关问题 更多 >
编程相关推荐