예를 들어 matplotlib에서 색상을 직사각형으로 설정하려면 어떻게해야합니까? 나는 인수 색상을 사용하려했지만 성공하지 못했습니다.Matplotlib에서 색상을 사각형으로 설정하는 방법은 무엇입니까?
내가 코드를 다음 있습니다 :
fig=pylab.figure()
ax=fig.add_subplot(111)
pylab.xlim([-400, 400])
pylab.ylim([-400, 400])
patches = []
polygon = Rectangle((-400, -400), 10, 10, color='y')
patches.append(polygon)
p = PatchCollection(patches, cmap=matplotlib.cm.jet)
ax.add_collection(p)
ax.xaxis.set_major_locator(MultipleLocator(20))
ax.yaxis.set_major_locator(MultipleLocator(20))
pylab.show()