Fixing a colormap with plot GIF
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everyone
I'm writing a code to produce a GIF that shows an optimization process, I wish to sequentially plot each line of my Dataset and color code one of my variables. The thing is that the colormap is updated while I go into the loop and I wish to have it fixed for the range of the variable.
I've tried several things to fix this but they don't seem to work, could somebody help me please?
figure('color',[1 1 1],'unit','normalized','position',[0.1 0.1 0.8 0.8])
g1 = subplot(2, 2, 1); g2 = subplot(2, 2, 2); g3 = subplot(2, 2, [3 4]);
colormap(hot)
cmap = colormap; %get current colormap
cmap=cmap([max(datas.U(:,1)) min(datas.U(:,1))],:); % set your range here
colormap(cmap); % apply new colormap
colorbar(g1)
colorbar(g2)
for i = 1 : length(datas.X)
scatter(g1, datas.X(1:i,2), datas.X(1:i,1), datas.X(1:i,5)*1000, datas.U(1:i),'Filled','MarkerEdgeColor','k');
%
xlabel(g1,'X1=A/m'), ylabel(g1,'X2=A/M')
xlim(g1, [1 11]), ylim(g1, [0.1 1])
colorbar(g1)
scatter(g2, datas.X(1:i,3), datas.X(1:i,4), datas.X(1:i,5)*1000, datas.U(1:i),'Filled','MarkerEdgeColor','k');
% colormap(hot(length(datas.U(:))));
colorbar(g2)
xlabel(g2,'T2'), ylabel(g2,'T1'),
xlim(g2, [170 270]), ylim(g2, [170 270])
plot(g3, [1:1:i], datas.U(1:i,1), 'o-b'); hold on
plot(g3, [1:1:i], datas.U(1:i,2), 'o-r'); hold on
xlim(g3, [0 45]), ylim(g3, [-30 10]);
pause(0.5)
drawnow,
end
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Blue finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!