Borrar filtros
Borrar filtros

Animation Slow Due to ColorBar.doUpdate Function

4 visualizaciones (últimos 30 días)
Joshua  Robinson
Joshua Robinson el 22 de Mayo de 2019
Comentada: Arno van der Heijden el 17 de Feb. de 2020
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

Respuestas (0)

Categorías

Más información sobre Animation en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by