필터 지우기
필터 지우기

Animation Slow Due to ColorBar.doUpdate Function

조회 수: 4 (최근 30일)
Joshua  Robinson
Joshua Robinson 2019년 5월 22일
댓글: Arno van der Heijden 2020년 2월 17일
I'm trying to animate a plot with a static colorbar on it.
For some reason a large percentage of my code runtime is spent in this ColorBar.doUpdate function, despite the fact that I am not manually changing any colorbar properties as the code runs.
Is there a way to force Matlab to keep the properties of the colobar static (and not even attempt to update the colorbar) even as the graph limits are updated?
Here is an example that mimics the issue I am seeing.
clear all
close all
% params
R = 10;
dtheta = deg2rad(1);
max_theta = 3*(2*pi);
% initalize figure
figure;
% xlim(1.5*R*[-1 1]); % static limits
% ylim(1.5*R*[-1 1]);
grid('on');
colorbar;
colormap('jet');
% main loop
rect = rectangle;
for theta=0:dtheta:max_theta
x = R*cos(theta);
y = R*sin(theta);
pos = [x y 1 1];
rect.Position = pos;
xlim(1.5*R*[-1 1]); % dynamic limits
ylim(1.5*R*[-1 1]);
drawnow;
end
If the axes' limits are static and there is no colorbar, the code runs in ~7.3 seconds on my machine.
If the axes' limits are updated in the for loop but there still is no colorbar, the code runs in ~12.6 seconds.
If the axes' limits are updated in the for loop and there is a colorbar, the code runs in ~24.7 seconds!
Capture.PNG

답변 (0개)

카테고리

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

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by