Set uicontrol position relative to a subplot
Mostrar comentarios más antiguos
Is it possible to set the position of a GUI control element (e.g. a slider) relative to a subplot's position rather than relative to the whole figure?
The code I'm trying to write can have a variable number of subplots and it would easiest if I could set the uicontrol 'Position' relative to the subplot. For example, I might have two or three subplots and I want a slider under each of them.
Thanks!
Respuesta aceptada
Más respuestas (2)
Joseph Cheng
el 6 de Mayo de 2015
well your explanation of the problem is exactly how you'd do it. you would first get the position of the subplot then perform the offset.
this isn't pretty but for a 2 min example it'll show you what you can accomplish
clf;
for ind =1:3
hsub(ind) =subplot(3,1,ind),plot(randi(10,1,10));
subpos = get(hsub(ind),'position');
hslide(ind) = uicontrol('style','slider')
set(hslide(ind),'units',get(hsub(ind),'units'))
slideoff = [-.05 -.05 0];
slidepos = get(hslide(ind),'position')
slidepos = [subpos(1:3)+slideoff slidepos(end)]
set(hslide(ind),'position',slidepos);
end
Mary
el 7 de Mayo de 2015
0 votos
Categorías
Más información sobre Subplots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!