Resizing my figure table
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I would like to ask how can I make my "PUSH" Buttons change their position when I enlarge my figure.
Currently my "PUSH" Buttons have the positions specified, and when i maximise the figure, my subplotted axes will change in position but the push buttons remain the same.
Thank you!
function []=plotting_8_figures()
S.fh = figure('units','pixels',...
'position',[350 100 1200 1000],...
'menubar','none',...
'numbertitle','off',...
'name','8 Figures axes',...
'resize','on');
for n=1:8
subplot(4,2,n)
end
S.pb(1) = uicontrol('style','push',...
'units','pixels',...
'position',[450 820 120 30],...
'fontsize',10,...
'string',['PUSH']);
S.pb(2) = uicontrol('style','push',...
'units','pixels',...
'position',[1000 820 120 30],...
'fontsize',10,...
'string',['PUSH']);
S.pb(3) = uicontrol('style','push',...
'units','pixels',...
'position',[450 600 120 30],...
'fontsize',10,...
'string',['PUSH']);
S.pb(4) = uicontrol('style','push',...
'units','pixels',...
'position',[1000 600 120 30],...
'fontsize',10,...
'string',['PUSH']);
S.pb(5) = uicontrol('style','push',...
'units','pixels',...
'position',[450 380 120 30],...
'fontsize',10,...
'string',['PUSH']);
S.pb(6) = uicontrol('style','push',...
'units','pixels',...
'position',[1000 380 120 30],...
'fontsize',10,...
'string',['PUSH']);
S.pb(7) = uicontrol('style','push',...
'units','pixels',...
'position',[450 160 120 30],...
'fontsize',10,...
'string',['PUSH']);
S.pb(8) = uicontrol('style','push',...
'units','pixels',...
'position',[1000 160 120 30],...
'fontsize',10,...
'string',['PUSH']);
set(S.pb(:),{'callback'},{{@pb1_call,S};{@pb2_call,S};{@pb3_call,S};{@pb4_call,S}...
;{@pb5_call,S};{@pb6_call,S};{@pb7_call,S};{@pb8_call,S}});
function [] = pb1_call(varargin)
close(S.fh)
end
function [] = pb2_call(varargin)
close(S.fh)
end
function [] = pb3_call(varargin)
close(S.fh)
end
function [] = pb4_call(varargin)
close(S.fh)
end
function [] = pb5_call(varargin)
close(S.fh)
end
function [] = pb6_call(varargin)
close(S.fh)
end
function [] = pb7_call(varargin)
close(S.fh)
end
function [] = pb8_call(varargin)
close(S.fh)
end
end
0 commentaires
Réponse acceptée
Chunru
le 27 Août 2021
A simple approach is to use normalized units for specifying position:
S.pb(1) = uicontrol('style','push',...
'units','normalized',...
'position',[0.2 0.4 0.2 0.1],... % adjust these values
'fontsize',10,...
'string',['PUSH']);
A more complicated approach is to use the callback function SizeChangedFcn.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!