How can I speed up drawnow when combined with 'get' function?
6 views (last 30 days)
Show older comments
Dear community,
I have been trying to speed up the use of drawnow, employed to update the x-axis (and thereby creating a horizontally 'moving' window along the plotted curve's trajectory), for a while now. The problem is that it is slowed down by a call to the get-function for fetching the live co-ordinates of my cursor, every time I move it over the figure. I have already tried a few things, such as
(1)
drawnow limitrate
(2)
the alternative use of
pause(0.005)
and combinations of the above attempts (with different pausing duration and calling the pause function only for multiples of iteration numbers such as 5). Unfortunately, nothing has resulted in the fluently updated figure with instant cursor coordinates that are acquired when I move my mouse.
Basically, the code that I use is
fig1 = figure;
set(fig1, 'WindowButtonMotionFcn', @mouseMove);
for n=1:1:numel(x)
axis([x(n) x(n+1) -1.2 1.2]);
set(gca, 'XTick', [])
set(gca, 'YTick', [])
% % drawnow
% % pause(0.005)
end
with x being the array with values for the horizontal axis (code for making the plot is omitted), and the mouseMove function being:
function mouseMove(varargin)
% Get live cursor coordinates
C = get(gca, 'CurrentPoint');
Anyone who knows how to tackle this issue?
Thank you in advance.
Silvano.
0 Comments
Answers (1)
Steven Lord
on 27 Jan 2022
So it sounds like you're trying to do horizontal panning. Is that correct? You can't actually pan the figure shown in this Answer but if you run that code in your MATLAB session you can pan. Because I used "xon" as the option to the pan function you can pan left and right but not up and down.
x = 0:720;
y = sind(x);
plot(x, y)
axis([0 180 -1 1])
pan xon
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!