Enlarge figure in MATLAB
Afficher commentaires plus anciens
I want to create figure that is enlarged, I use:
fig = figure(1);
set (fig, 'Units', 'normalized', 'Position', [0,0,1,1]);
The dialogue is enlarged. What should I do if I also want the graph inside this dialogue also enlarged? Although I can use "zoom in" and "pan" in the dialogue to enlarge and reposition my graph I want this be done automatically by codes.
Update of my question:
I am trying to plot 3D block which the value is represented by color of each small unit block: clear; close all; clc;
fig = figure(1);
set (fig, 'Units', 'normalized', 'Position', [0,0,1,1]);
fig_color='w'; fig_colordef='white';
cMap=jet(256); %set the colomap using the "jet" scale
faceAlpha1=1;
faceAlpha2=0.65;
edgeColor1='none';
edgeColor2='none';
NumBoxX=100;%box number in x direction
NumBoxY=100;%box number in y direction
NumBoxZ=5;%box number in z direction
fid = fopen('Stress.dat','r');
datacell = textscan(fid, '%f%f%f%f%f%f%f%f%f%f%f%f%f%f');
fclose(fid);
all_data = cell2mat(datacell);
M=zeros(NumBoxX,NumBoxY,NumBoxZ);
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,4); %the forth 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('\sigma_{xy}','fontsize',20);
xlabel('y','fontsize',20);ylabel('x','fontsize',20);
zlabel('z','fontsize',20); hold on;
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([min(M(:)) max(M(:))]);
cb = colorbar;
set(get(cb,'title'),'string','Stress (MPa)','fontsize',20);
lbpos = get(cb,'title'); % get the handle of the colorbar title
set(lbpos,'units','normalized','position',[0,1.04]);
zoom(1.9);
3 commentaires
Andreas Justin
le 22 Oct 2015
Modifié(e) : Andreas Justin
le 22 Oct 2015
- You either want to set the units of the axes also to normalized, before setting the position of figure
- or you want to set the SizeChangedFcn of the figure and handle there what you want to do
fig.SizeChangedFcn = @(source,event) mySizeChangedFcn(source,event);
Kelvin
le 23 Oct 2015
Kelvin
le 23 Oct 2015
Réponses (0)
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!