仅在matplotlib中绘制带有边框的矩形 [英] Drawing rectangle with border only in matplotlib
本文介绍了仅在matplotlib中绘制带有边框的矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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 = plt.gca()
currentAxis.add_patch(Rectangle((someX - .1, someY - .1), 0.2, 0.2,alpha=1))
plt.show()
这给出了:
但我想要的是一个只有蓝色边框且内部透明的矩形.我该怎么办?
But what I want is a rectangle with only a blue border and inside of it to be transparent. How can I do this?
推荐答案
您只需要将 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'))
这篇关于仅在matplotlib中绘制带有边框的矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文