Changing xlim & ylim of axes sluggish

조회 수: 5 (최근 30일)
Dan
Dan 2013년 12월 18일
댓글: Dan 2013년 12월 20일
I implemented my own pan & zoom functionality which adjusts the xlim & ylim of an axes as the user moves the mouse. Although this works OK, it's a bit sluggish & "laggy". I'm guessing that the data coming from the mouse is overwhelming the systems ability to change the axes properties.
Does this sound reasonable? If so, does the axes have a "busy updating" flag I can test? Or is there some other explanation?
Any ideas?
TIA
Dan
  댓글 수: 3
Dan
Dan 2013년 12월 18일
A lot! ;-) I neglected to mention that the axes contains an image.
José-Luis
José-Luis 2013년 12월 18일
That might the source of your problem. The image is re-plotted every time you refresh your axes. Please try with fewer data to see if that's the problem.

댓글을 달려면 로그인하십시오.

답변 (2개)

David Sanchez
David Sanchez 2013년 12월 18일
You have too many processes trying to run at the same time. Even when it sounds incoherent, insert a very short pause right after reading the mouse position
pause(0.0001);
That will refresh the buffer ( or something like that ) and the graphics will be plotted less "laggy".
  댓글 수: 1
Dan
Dan 2013년 12월 19일
I think we are both close to the answer.... but not quite there. I'm actually doing this inside GUIDE so I'm not certain where to put this pause. I tried putting it on the first line inside the function that gets triggered when the mouse moves (WindowButtonMotionFcn) but it didn't seem to do much. In fact.... it almost feels like this would make things worse but I'm not certain. Maybe I need a careful insertion of "drawnow"? This is tricky.

댓글을 달려면 로그인하십시오.


Kelly Kearney
Kelly Kearney 2013년 12월 20일
Not sure if this is exactly the effect you're going for, but for panning around an image via mouse movement, I've found this function: zoom2cursor to be very well-done, and I've used that code as a template to pan around some very large images without any noticeable latency.
  댓글 수: 1
Dan
Dan 2013년 12월 20일
Thanks for the info on zoom2cursor. I'm both pleased and disappointed that the function seems to have similar laggy/jerky behavior. (Pleased because Brett knows his stuff so I'm doing something right). So... I'm thinking it's perhaps either my computer or perhaps I need to play with the "interruptible" and/or "busy action" properties of the axes.
Thanks again
Dan

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by