pythonmatplotlib怎么设置柱面_python – 如何在Matplotlib中将颜色设置为Rectangle?

我无法让你的代码工作,但希望这将有助于:

import matplotlib

import matplotlib.pyplot as plt

fig = plt.figure()

ax = fig.add_subplot(111)

rect1 = matplotlib.patches.Rectangle((-200,-100), 400, 200, color='yellow')

rect2 = matplotlib.patches.Rectangle((0,150), 300, 20, color='red')

rect3 = matplotlib.patches.Rectangle((-300,-50), 40, 200, color='#0099FF')

circle1 = matplotlib.patches.Circle((-200,-250), radius=90, color='#EB70AA')

ax.add_patch(rect1)

ax.add_patch(rect2)

ax.add_patch(rect3)

ax.add_patch(circle1)

plt.xlim([-400, 400])

plt.ylim([-400, 400])

plt.show()

生产:

你可能感兴趣的:(pythonmatplotlib怎么设置柱面_python – 如何在Matplotlib中将颜色设置为Rectangle?)