フィルターのクリア

Animation Slow Due to ColorBar.doUpdate Function

4 ビュー (過去 30 日間)
Joshua  Robinson
Joshua Robinson 2019 年 5 月 22 日
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 件のコメント
Arno van der Heijden
Arno van der Heijden 2020 年 2 月 17 日
Did you ever find the answer to this?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by