Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide / Invisible Matplotlib figure

I have a question, not sure if its difficult or not, but i tried to google the answer. nothing worthy.

I have figure as global, which can be accessed in all threads.

but it appears in the beginning of the program,

I want to hide or making it invisible in the starting of the script then at one point in the code make it available or visible.

Is there is any Matplotlib like visible False or something

i use this:

plt.ion()

fig = plt.figure(visible=False)

ax =fig.add_subplot(111)

Thanks in advance

like image 293
Hasan Avatar asked Jan 31 '13 15:01

Hasan


People also ask

How do I hide a figure from being shown in Matplotlib?

Use matplotlib. pyplot. close() to hide a figure from being shown.

How do you hide a figure in Python?

Avoid Display With ioff() Method We can turn the interactive mode off using matplotlib. pyplot. ioff() methods. This prevents figure from being displayed.

How do I hide Xlabel in Matplotlib?

To hide or remove X-axis labels, use set(xlabel=None). To display the figure, use show() method.

How do you hide a plot?

Right-click on a data plot and select Hide Data Plot or Hide Others from the shortcut menu. In the Plot Details dialog box, clear or check the box next to the data plot.


1 Answers

I have to do the same thing that you're asking for, but I put the figure on a canvas first using this process (NOTE: this uses matplotlib, pyplot, and wxPython):

#Define import and simplify how things are called
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
import matplotlib.pyplot as plt

#Make a panel
panel = wx.Panel(self)

#Make a figure
self.figure = plt.figure("Name")
#The "Name" is not necessary, but can be useful if you have lots of plots

#Make a canvas
self.canvas = FigureCanvas(panel, -1, self.figure)

#Then use
self.canvas.Show(True)
#or
self.canvas.Show(False)

#You can also check the state of the canvas using (probably with an if statement)
self.canvas.IsShown()
like image 73
Brandon Boyce Avatar answered Sep 20 '22 18:09

Brandon Boyce