The Axes Tag keeps on deleting....

Every time I open the project - the Axes Tag is empty. That causes the background picture I it to not appear.
Any idea?

Risposte (2)

Jan
Jan il 20 Feb 2013
Modificato: Jan il 20 Feb 2013
As reply to your comment to Image Analysts answer:
You can fix this by the shown method to set 'NextPlot' to 'add':
h = axes('tag', 'theTag', 'NextPlot', 'add');
Then new object added by so called high-level graphic routines do not clear formerly created objects and do not reset some properties of the parent object anymore. I create all AXES objects with this property and whenever I want an already existing object to be deleted, I do this explicitly. The less I let Matlab guess what I want, the less chances Matlab has to make mistakes.
I follow the same principle for low-level functions also: The high-level function plot() creates a line object. calling line directly is faster, has less side-effects, but it is less convenient e.g. for setting markers. But even then specifying the axes handle as 'Parent' property has advantages instead of relying, that the wanted axes is the current object: When a TIMER callback activates another axes, the results look very confusing.

7 Commenti

1. Where do I plance this? In the CreateFcn function of the axes?
2a. Is this the syntax or I need to change all the parameters to mine? (for ex. 'tag' should be 'Background_Picture' if the axes Tag is such?)
2b. If so - What are 'theTag', NextPlot and 'add'?
function Background_Picture_CreateFcn(hObject, eventdata, handles)
axes(hObject)
imshow('apple.png')
I places the following lines:
h = axes('tag', 'Background_Picture', 'NextPlot', 'add');
imshow('apple.png')
in the function:
function GuiSimulation_OpeningFcn(hObject, eventdata, handles, varargin)
and got the error message:
Insufficient Java heap memory to continue operation
Image Analyst
Image Analyst il 20 Feb 2013
Modificato: Image Analyst il 20 Feb 2013
I never put anything in the CreateFcn for the axes, or any other control. If you want to show some image at startup, put the imshow() in the OpenFcn for the entire figure, or the OutputFcn for the entire figure.
axes(handles.Background_Picture);
imshow('apple.png');
You never need to put anything in any control's CreateFcn. I get along just fine never doing that. And I put up splash images in my axes for every GUI I make with no problem. Try that.
Nimrodb
Nimrodb il 20 Feb 2013
IA: The problem is when I open the guide. When I do that - the axes tag is empty - in that case - you solution will not help me cause no matter where I open it - Matlab will not know who Background_Picture is
Image Analyst
Image Analyst il 20 Feb 2013
Modificato: Image Analyst il 20 Feb 2013
I'd call the Mathworks about it. I repeatedly open fig files in GUIDE and I never have properties of controls mysteriously vanish. If it were me, I'd call them.
Nimrodb
Nimrodb il 24 Feb 2013
IA: I did - no answer :/
But thanks.
As long as I do not turn on the GUIDE - all is good. The problem happens when I turn the GUIDE on - then the Tag is gone.
It should answer - they have an automated/computerized phone answering system. Try calling them during normal business hours.

Accedi per commentare.

Image Analyst
Image Analyst il 19 Feb 2013

0 voti

How are you opening "the project"? In GUIDE? And then you double click on an axes to bring up the property inspector and the tag property is empty? That seems weird or impossible.

6 Commenti

Reminds me of the question we had a number of months ago in which someone was trying to place a background picture on a specific axis but the tag on the axis kept disappearing.
Jan
Jan il 20 Feb 2013
Yes, Walter, and hold on solved this, because it preserves the tag even when high-level graphic functions like image and plot draw to the axes.
Very strange. I've used plot() and image() for years and they have never obliterated the tag I've assigned to an axes, essentially removing the control's field from the GUI handle structure. For example if I have an axes called axesImage (that's the "tag" property as seen in Property Inspector), and I call image(grayImage), and it allegedly then destroys the tag property, so that the next time I call axes(handles.axesImage) it says it doesn't know axesImage. I've never had that happen. I don't see why any function would not preserve the tag.
@Image Analyst: I'm not sure if I understand you. I meant:
h = axes('tag', 'theTag');
plot(1:10);
get(h, 'tag') % >> ''
delete(h);
h = axes('tag', 'theTag', 'NextPlot', 'add'); % Or: hold on
plot(1:10);
get(h, 'tag') % >> 'theTag'
But if the handle is stored in the handles struct, it is still valid. The same happens for other high-level functions. And I agree that this is a strange behavior: Why should adding a graphic object remove the tag automatically? The tag is a property of the axes object, and should not depend on its children.
Nimrodb
Nimrodb il 20 Feb 2013
Guys, it looks like you also encountered my problem.
Jan, I'm not sure if you saw this behavior or not (not sure what this code is for) - but your questions are valid and that is the question for the answer I'm looking for - Why should this happen? End more - how to fix this?
You could probably fix it using GUIDE. I use GUIDE and that never happens to me.

Accedi per commentare.

Categorie

Scopri di più su Creating, Deleting, and Querying Graphics Objects in Centro assistenza e File Exchange

Richiesto:

il 19 Feb 2013

Community Treasure Hunt

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

Start Hunting!

Translated by