0

I'm using matplotlib to show a picture but I want to hide the window frame.

I tried the code frameon=False in plt.figure() but the window frame is still there. Just the background color turns to grey.

Here is the code and running result. The picture was showing with the window even I add the "frameon=False" in the code.

Link for issue screenshot

2
  • I want the QR code can be showed on screen only. No window element around it. Thx. Commented Sep 30, 2017 at 14:48
  • The hardware is raspberry pi 3b and the operation system is raspbain. Thanks. Commented Sep 30, 2017 at 15:25

1 Answer 1

2

frameon suppresses the figure frame. What you want to do is show the figure canvas in a frameless window, which cannot be managed from within matplotlib, because the window is an element of the GUI that shows the canvas. Whether it is possible to suppress the frame and how to do that will depend on the operating system and the matplotlib backend in use.

Let's consider the tk backend.

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot! It works! I also can use plt.get_current_fig_manager().window.wm_geometry("400x400+50+1000") to set the picture size and position.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.