隐藏使用matplotlib绘制的图像周围的窗口框架

时间:2017-09-30 14:46:03

标签: python matplotlib

我使用matplotlib来显示图片,但我想隐藏窗框。

我在#include <stdio.h> #include <stdlib.h> struct block{ int num; }; struct block *free_block(){ struct block *b = NULL; return b; } int main(int argc, char *argv[]) { struct block *b; b = free_block(); if(b == NULL) // Checking whether pointer is returned printf("\n Recieved NULL \n"); return 0; } 中尝试了代码frameon=False,但窗口框架仍在那里。只是背景颜色变成灰色。

这是代码和运行结果。即使我添加&#34; frameon = False&#34;在代码中。

Link for issue screenshot

1 个答案:

答案 0 :(得分:1)

frameon抑制数字框架。你想要做的是在无框窗口中显示图形画布,这不能在matplotlib中进行管理,因为窗口是GUI的一个元素,用于显示画布。是否可以抑制帧以及如何执行此操作取决于操作系统和正在使用的matplotlib后端。

让我们考虑 tk后端

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()

enter image description here