0

Is it possible to enlarge a 3D patch without altering the size of the colorbar? My original picture is like this one:

enter image description here

I just want to enlarge the block in the middle of the figure keeping the colorbar unchanged. I used zoom(1.9) before, it is good but since I need to use a for loop to read sequential files to plot different graphs and make video, the graph became larger and larger so it seems that I need another method to enlarge the plot.

Update: my codes

set(gcf,'Renderer','zbuffer'); %eliminate unnecessary background and prevent stationary video - Important!
vid = VideoWriter('afation.avi'); %Create a avi file 
vid.Quality = 100;
vid.FrameRate = 15;
open(vid); %Open the avi file so that films can be put into it later on

for ii=FirstFile:FileInterval:LastFile  

fid = fopen(filename,'r');
datacell = textscan(fid, '%f%f%f%f%f%f%f%f'); %There are 8 columns to be read so there are 8 %f
fclose(fid);

all_data = cell2mat(datacell); %converted into a matrix containing all the dis. density info. for every simulation cell

M=zeros(NumBoxX,NumBoxY,NumBoxZ); %create a matrix of 50x50x5,representing array of simulation cells
% % the following loops assign the dislocation density from all_data to M
for i=1:NumBoxX            
    for j=1:NumBoxY        
        for k=1:NumBoxZ     
            num=k+NumBoxZ*(j-1)+NumBoxZ*NumBoxY*(i-1);
            M(i,j,k)=all_data(num,ValCol); %the ValCol column of all_data is dislocation density 
        end
    end
end

indPatch=1:numel(M);
[F,V,C]=ind2patch(indPatch,M,'v'); %Call the function ind2patch in order to plot 3D cube with color

title('AA in different cells','fontsize',20);%set title \sigma_{xx}
xlabel('y','fontsize',20);ylabel('x','fontsize',20); zlabel('z','fontsize',20); hold on;
set(get(gca,'xlabel'),'Position',[5 -50 30]); %set position of axis label
set(get(gca,'ylabel'),'Position',[5 50 -15]);
set(get(gca,'zlabel'),'Position',[64 190 -60]);
patch('Faces',F,'Vertices',V,'FaceColor','flat','CData',C,'EdgeColor','k','FaceAlpha',0.5);
axis equal; view(3); axis tight; axis vis3d; grid off;
colormap(cMap);
caxis([MinDis MaxDis]); %set the range of the colorbar   %caxis([min(M(:)) max(M(:))]); %range of the colorbar according to one file only
cb = colorbar;     % create the colorbar
set(get(cb,'title'),'string','aaty(m^{-2})','fontsize',20); 

lbpos = get(cb,'title'); % get the handle of the colorbar title
set(lbpos,'units','normalized','position',[0,1.04]);
MyAxes=gca;
set(MyAxes,'Units','Normalized','position',[0.05,0.1,0.8,0.8]);

zoom(1.9);
writeVideo(vid, getframe(gcf)); %get the picture and put in the avi file with the handle "vid"

end

close(vid); %close the avi file after putting all the films into it
% winopen('ggggon.avi'); %play the movie

I put the zoom in the for loop because I need to enlarge the picture one by one and put them into my avi file to make movie.

Kelvin S
  • 341
  • 2
  • 4
  • 13
  • Just use zoom once when you declare the figure, then keep its handle in memory and just update its inner data when you want to plot again – BillBokeey Oct 30 '15 at 08:00
  • @BillBokeey I put the zoom command just after fig = figure(1); %These two lines maximize the figure dialogue set (fig, 'Units', 'normalized', 'Position', [0,0,1,1]); zoom(1.9); But it doesn't enlarge at all – Kelvin S Oct 30 '15 at 08:03
  • You said in your question that it enlarges the figure everytime you call it. Does it or does it not? – BillBokeey Oct 30 '15 at 08:04
  • @BillBokeey I updated my questions with codes, I put the zoom in the for loop because I need to enlarge the picture one by one and put them into my avi file to make movie. – Kelvin S Oct 30 '15 at 08:20
  • isn't it already large enough when you set the width and height of your axes manually? – BillBokeey Oct 30 '15 at 08:23
  • @BillBokeey Without the zoom command the picture is like that shown in my question and I want it to be larger. With putting zoom in the for loop the image become larger and larger whenever a new set of data is read and plot. – Kelvin S Oct 30 '15 at 08:26
  • @BillBokeey I finally give up trying other method and add this for loop: if ii==FirstFile zoom(1.8); else zoom(1/1.8); zoom(1.8); end – Kelvin S Oct 30 '15 at 08:57
  • Well it's not beautiful but if it works it's good ^^ – BillBokeey Oct 30 '15 at 08:59
  • @BillBokeey Actually just need if ii==FirstFile zoom(1.8); end The second part is not needed. – Kelvin S Oct 30 '15 at 09:12

0 Answers0