×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to create and show graphics more of one time over the same axes?

How to create and show graphics more of one time over the same axes?

How to create and show graphics more of one time over the same axes?

(OP)


Hi anyone,

    My application contains a graphic called ‘AxeSpot’. To show it I push a button. The button’s callback executes the following code:

% Get the main figure’s handle
hfmain=findobj('Tag','FigMain'); % Main Figure’s handle.

% Create the ‘AxeSpot’ axes (which is a main figure’s child) with certains properties.
h1 = axes('Parent',hfmain, ...
    'Units','pixels', ...
    'Position',[181 228 177 104], ...
    'Tag','AxeSpot', ...
    'Color',[1 1 1], ...
    'Layer','top', ...
     'Visible','on',...
     'XColor',[1 1 1], ...
     'YColor',[1 1 1]);

hspot=findobj('Tag','AxeSpot');     % This sentence asign a handle to ‘AxeSpot’ axes.
axes(hspot);                         % This sentence select ‘AxeSpot’ as current axes.
set(hspot,'NextPlot','add');          % This sentence add the nexplot to ‘AxeSpot’ axes.
spot(v_out);                          % This is the function that show the plot over the %‘AxeSpot’ axes.

    But there is a trouble: The first time I push the button, the graphics is created and the plot is added to ‘AxeSpot’ axes. However, the following times I push the button, the program does not work and an error arises. The error says: hfmain invalid handle in line …. The program line of which I talk is that where I create the axes again:

h1 = axes('Parent',hfmain, ...
    'Units','pixels', ...
    'Position',[181 228 177 104], ...
.
.
.
.
    Which is the problem reason? Why does it not work? Do you know how to solve it?

    Thanks in advance,

      Cris


RE: How to create and show graphics more of one time over the same axes?

Hi,
The trouble is hidden somewhere. But if you use findobj again just before creating the axes you will solve it anyway. In general it is better to hide objects (setting the 'visible' property to 'off') then recreate it again and again.

Joe
BSTEX - Equation viewer for Matlab
http://www.geocities.com/bstex2001

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources