Hello. I have data I'm using to make a movie from surface plots. I'm trying to add a fixed color bar with a width about 1/2 times the default, but adjusting the width causes the color bar to overlap each plot. My code only ends up correcting this for the first frame, but does not correct it for the rest of them. Any suggestions would be greatly appreciated.
set(gcf,'visible','off') mov(pf) = struct('cdata',[],'colormap',[]);for p = 1:pf surf(X(:,:,p),Y(:,:,p),P(:,:,p)); grid('off') xlabel('x(m)'); ylabel('y(m)'); zlabel('|Grad(P)| (Pa/m)'); axis([x0 xf y0 yf z0 zf]) titleInfo = cell(3,1); titleInfo{1,1} = '|GradP| vs x and y'; titleInfo{2,1} = ['U = ',num2str(u,'%3.2f'),' (m/s)']; titleInfo{3,1} = ['t = ',num2str(t(p),'%3.2f'),' (s)']; title(titleInfo); view(50,45) colormap jet caxis manual caxis([z0 zf]) *cbar = colorbar; ax = gca; axpos = ax.Position; cpos = cbar.Position; cpos(3) = 0.5*cpos(3); cbar.Position = cpos; ax.Position = axpos;* mov(p) = getframe(gcf);endclose('all')set(gcf,'visible','on')
Best Answer