43382

Hide the window frame around image plotted with matplotlib

Question:

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.

<img alt="Link for issue screenshot" class="b-lazy" data-src="https://i.stack.imgur.com/xVCTR.png" data-original="https://i.stack.imgur.com/xVCTR.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

Answer1:

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 <strong>tk backend</strong>.

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

<a href="https://i.stack.imgur.com/eVTg9.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/eVTg9.png" data-original="https://i.stack.imgur.com/eVTg9.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

Recommend

  • Problem with joining db tables
  • How can I get a borderless child window to re-scale to current screen in multi-monitor setup?
  • How do I build a list of elements extracted from a list of tuples in Erlang?
  • VB6 how to get C-like integer overflow
  • Suppress warnings using tryCatch in R
  • What should I use to create a Windows GUI?
  • Sending a variable with a button-command (python 3.3 / tkinter) [duplicate]
  • Centering a Tkinter Toplevel window in both windows and remote X11?
  • How to display rendered html content in text widget of tkinter in python 3.4.x
  • Taking input from user and returning an answer in TKinter
  • Python : How to center Label in tkinter window
  • resize image using tkinter
  • Launching a new command window from Golang in Windows
  • css font-size and line-height not matching the baseline
  • Can't access Tomcat 7 Manager app when running from Eclipse
  • Certain Arabic text gets incorrectly shown while other Arabic text gets showed normally?
  • Wrapping a c#/WPF GUI around c++/cli around native c++
  • How to implement Deep Linking in Roku SG application?
  • How to draw a line dynamically in android [duplicate]
  • Exception gevent.hub.LoopExit: LoopExit('This operation would block forever',)
  • Can I programmatically choose the Android layout folder?
  • C: Incompatible pointer type initializing
  • why xml file does not aligned properly after append the string in beginning and end of the file usin
  • Chart.js Multiple dataset
  • x64 applications using gdi+: what are the consequences on performance?
  • ActiveRecord query for a count of new users by day
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Controls, properties, events and timers running in design time
  • Knitr HTML Loop - Some HTML output, some R output
  • Updated Ionic CLI but shows previous version (Windows)
  • Weird JavaScript statement, what does it mean?
  • Benchmarking RAM performance - UWP and C#
  • Angular 2 constructor injection vs direct access
  • Java static initializers and reflection
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • Android Google Maps API OnLocationChanged only called once
  • Django query for large number of relationships
  • UserPrincipal.Current returns apppool on IIS
  • Android Heatmap on canvas or ImageView