Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: GUI axes slowdown

Subject: GUI axes slowdown

From: Daphne

Date: 9 Jan, 2008 19:58:02

Message: 1 of 3


I have a complex GUI that does a repetative task on an
image every time the user presses a pushbutton (supposedly
after they have changed a parameter). Then the gui calls
to axes in it and replots the image and whatever changes
were made.
What I have noticed is that every time I do this, there is
a slowdoen in the time it takes to do the same calculation
(even with the same parameters) this starts at 1.8 sec -->
grows to infinity (?).

Using the profiler I saw that the functions that pop up as
the trouble makers are
- axes(handles.axes3);
- linkaxes(ax);

Any idea how to stop this slowdown from happening?
I've tried to clear axes and ax... but (of course) didn't
help.

Thanks,
Daphne

Subject: GUI axes slowdown

From: matt dash

Date: 9 Jan, 2008 23:34:02

Message: 2 of 3

I'm not sure about linkaxes, but I've also noticed that the
axes command is extremely slow in gui's containing multiple
axes. I've never noticed it getting slower each time though
(but I wouldn't rule it out.) Maybe this is because you are
actually creating new axes each time without reusing the old
ones?

Luckily, there are very few (if any) cases where you have to
use the axes command. Instead of using axes() to make an
axes current, just specify it as the parent directly in your
plotting commands. most plotting commands can take the
target axes as the first argument, or using the 'parent'
property. (Note there are a few exceptions, like if you're
using mapping toolbox commands) I usually find this is
helpful anyway since it makes it easier to keep track of
exactly where your plots are going.

examples:
plot(handles.axes3,x,y)
line(x,y,'parent',handles.axes3)

Or if you're changing a plot that already exists, always
refer to it directly by its handle instead of relying on gca.

Subject: GUI axes slowdown

From: Stephane Carlier

Date: 10 Jan, 2008 16:22:02

Message: 3 of 3

First make sure you don't have any "hold on" that holds
older objects (even they may be not visible).

Then when you plotting, don't try to re-create new object,
instead, using set function. For example, suppose you
need to replot the image in one of the axes.
At the first iteration:
handles.hImage = image(X1);
At the second iteration, only update the image 'CData'
property instead of re-drawing it.
set(handles.hImage, 'CData', X2)

Use this technique for all other graphic objects such
as line, etc. Notice you can set "Visible" properties
if you don't want to show a particular graphic object.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
gui axes Daphne 9 Jan, 2008 15:00:08
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics