且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

仅在matplotlib中绘制带有边框的矩形

更新时间:2022-06-19 05:16:38

您只需要将 facecolor 设置为字符串"none"(而不是python None )

You just need to set the facecolor to the string 'none' (not the python None)

from matplotlib import pyplot as plt
from matplotlib.patches import Rectangle
someX, someY = 0.5, 0.5
fig,ax = plt.subplots()
currentAxis = plt.gca()
currentAxis.add_patch(Rectangle((someX - 0.1, someY - 0.1), 0.2, 0.2,
                      alpha=1, facecolor='none'))