Python 隐藏使用matplotlib打印的图像周围的窗口边框

Python 隐藏使用matplotlib打印的图像周围的窗口边框,python,matplotlib,Python,Matplotlib,我正在使用matplotlib显示图片,但我想隐藏窗框 我尝试了plt.figure()中的代码frameon=False,但窗口框架仍然存在。只是背景颜色变为灰色 下面是代码和运行结果。即使我在代码中添加了“frameon=False”,该图片仍显示在窗口中 frameon取消显示图形边框。您要做的是在无框架窗口中显示图形画布,该窗口无法从matplotlib中管理,因为该窗口是显示画布的GUI元素。是否可以抑制帧以及如何抑制帧将取决于操作系统和正在使用的matplotlib后端 让我们考虑

我正在使用matplotlib显示图片,但我想隐藏窗框

我尝试了
plt.figure()
中的代码
frameon=False
,但窗口框架仍然存在。只是背景颜色变为灰色

下面是代码和运行结果。即使我在代码中添加了“frameon=False”,该图片仍显示在窗口中


frameon
取消显示图形边框。您要做的是在无框架窗口中显示图形画布,该窗口无法从matplotlib中管理,因为该窗口是显示画布的GUI元素。是否可以抑制帧以及如何抑制帧将取决于操作系统和正在使用的matplotlib后端

让我们考虑<强> TK后端p>

import matplotlib
# make sure Tk backend is used
matplotlib.use("TkAgg")  
import matplotlib.pyplot as plt
# turn navigation toolbar off
plt.rcParams['toolbar'] = 'None'

# create a figure and subplot
fig, ax = plt.subplots(figsize=(2,2))
#remove margins
fig.subplots_adjust(0,0,1,1)
# turn axes off
ax.axis("off")
# show image
im = plt.imread("https://upload.wikimedia.org/wikipedia/commons/8/87/QRCode.png")
ax.imshow(im)

# remove window frame
fig.canvas.manager.window.overrideredirect(1)

plt.show()

frameon
取消显示图形边框。您要做的是在无框架窗口中显示图形画布,该窗口无法从matplotlib中管理,因为该窗口是显示画布的GUI元素。是否可以抑制帧以及如何抑制帧将取决于操作系统和正在使用的matplotlib后端

让我们考虑<强> TK后端p>

import matplotlib
# make sure Tk backend is used
matplotlib.use("TkAgg")  
import matplotlib.pyplot as plt
# turn navigation toolbar off
plt.rcParams['toolbar'] = 'None'

# create a figure and subplot
fig, ax = plt.subplots(figsize=(2,2))
#remove margins
fig.subplots_adjust(0,0,1,1)
# turn axes off
ax.axis("off")
# show image
im = plt.imread("https://upload.wikimedia.org/wikipedia/commons/8/87/QRCode.png")
ax.imshow(im)

# remove window frame
fig.canvas.manager.window.overrideredirect(1)

plt.show()

我希望二维码只能在屏幕上显示。周围没有窗口元素。硬件是raspberry pi 3b,操作系统是raspbain。谢谢。我想二维码只能在屏幕上显示。周围没有窗口元素。硬件是raspberry pi 3b,操作系统是raspbain。谢谢,非常感谢!它起作用了!我还可以使用plt.get_current_fig_manager().window.wm_geometry(“400x400+50+1000”)设置图片大小和位置。非常感谢!它起作用了!我还可以使用plt.get_current_fig_manager().window.wm_geometry(“400x400+50+1000”)设置图片大小和位置。