Drawing rectangle with border only in matplotlib

前端 未结 2 1530
情歌与酒
情歌与酒 2021-02-03 22:10

So I found the following code here:

from matplotlib import pyplot as plt
from matplotlib.patches import Rectangle
someX, someY = 0.5, 0.5
plt.figure()
currentAxis         


        
2条回答
  •  Happy的楠姐
    2021-02-03 22:47

    You should set the fill=None.

    from matplotlib import pyplot as plt
    from matplotlib.patches import Rectangle
    
    someX, someY = 0.5, 0.5
    plt.figure()
    currentAxis = plt.gca()
    currentAxis.add_patch(Rectangle((someX - .1, someY - .1), 0.2, 0.2, fill=None, alpha=1))
    plt.show()
    

    enter image description here

提交回复
热议问题