Effacer les filtres
Effacer les filtres

Animation Slow Due to ColorBar.doUpdate Function

4 vues (au cours des 30 derniers jours)
Joshua  Robinson
Joshua Robinson le 22 Mai 2019
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
  1 commentaire
Arno van der Heijden
Arno van der Heijden le 17 Fév 2020
Did you ever find the answer to this?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by