How do I stop figures from stealing focus without having to create a global variable?

10 visualizzazioni (ultimi 30 giorni)
I'm running nonlinear FE analysis and adding load/displacement points for every iteration using animated line. The function that does the plotting right now does not have access to the figure handle, but I do know the figure number, so I end up having to use figure(1). The problem is figure() will by default make the image pop, which prevents me from doing anything on the computer while the code is running. I've seen some answers to similar questions saying that this should be used:
set(0,'CurrentFigure',figHandle);
But right now, unless I make the figure handle global or pass it to every function until it gets to where I need it to be I can't use this structure. Is there a work around this? Maybe using tags on the figures?

Risposte (1)

Steven Lord
Steven Lord il 4 Feb 2019
Are you're sharing the handle to the graphics object that you're updating among the functions that update it? If so, ask that object what its ancestor figure is. Assuming h is the handle to the graphics object, f is its ancestor figure.
f = ancestor(h, 'figure')
But I'm curious -- why do you need to do anything with the figure handle?
  2 Commenti
holyoli
holyoli il 4 Feb 2019
I am not sure I understand what you asked me about the graphics object. I assume you're asking if I'm not sharing the figure handle (when I initialise it) to the function that updates it? If so, the answer is no. The code I'm using does not belong to me and I'm trying not to change it much.
All I need to do is make the figure current without having to call figure(), because figure makes the image pop on screen.
Jess
Jess il 11 Gen 2021
I have a similar question. I can't speak for why the OP needs the figure handle, but I send the figure handle to a routine that beautifies and saves the figure in a specified format.

Accedi per commentare.

Categorie

Scopri di più su Graphics Object Programming in Help Center e File Exchange

Prodotti


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by