uicontrol radiobutton label text is offset vertically

See attached image. Is the alignment between the radiobuttons and the text correct? To me it looks like the text is too high. Is there a way to control this?

4 comentarios

Stephen23
Stephen23 el 20 de Abr. de 2025
Editada: Stephen23 el 20 de Abr. de 2025
There is no documented "VerticalAlignment" property:
Most likely this behavior depends on your OS / Java / MATLAB version, which you have not told us.
uicontrol('Style','radiobutton', 'String','Micro')
CM
CM el 20 de Abr. de 2025
Movida: Walter Roberson el 20 de Abr. de 2025
I get similar alignment to you when I run that command by itself, but the text seems smaller relative to the circle.
I am running Matlab 2023b on Windows 11 Home 24H2, Java 1.8.0_202-b08.
Comparing with your one line example, my code does seem to lift the text vertically somehow. I'll have a play around and see if I can figure out how. I am using a panel inside a grid inside a tab and have done a lot of tweeking with the alignments, so not real sure where to look.
Walter Roberson
Walter Roberson el 20 de Abr. de 2025
Editada: Walter Roberson el 20 de Abr. de 2025
I checked, and there are no apparent internal properties for controlling text position or text alignment for uicontrol()
Give this a go. I get higher text on the second one.
uicontrol('Style', 'radiobutton', 'String', 'Micro')
figWindow = uifigure('HandleVisibility', 'on');
uicontrol('Style', 'radiobutton', 'String', 'Micro')

Iniciar sesión para comentar.

Respuestas (1)

Deepak
Deepak el 5 de Jun. de 2025
Hi @CM,
I understand that you are noticing a slight misalignment between the radio buttons and their text labels when using "uicontrol('Style', 'radiobutton')", particularly when used inside a "uifigure". The "uicontrol" does not provide internal properties to control the vertical text alignment, so the text might appear slightly higher or off-center.
If you are working in a modern UI context, a better alternative is to use App Designer-style components such as "uibuttongroup" with "uiradiobutton", which offer improved layout and text alignment. Here is an example:
fig = uifigure;
bg = uibuttongroup(fig, 'Position', [100 100 200 100]);
uiradiobutton(bg, 'Text', 'Micro', 'Position', [10 60 100 20]);
uiradiobutton(bg, 'Text', 'Micro', 'Position', [10 40 100 20]);
uiradiobutton(bg, 'Text', 'Equal', 'Position', [10 20 100 20]);
Please find attached the documentation of functions used for referernce:
I hope this helps.

Categorías

Más información sobre Interactive Control and Callbacks en Centro de ayuda y File Exchange.

Productos

Versión

R2023b

Preguntada:

CM
el 20 de Abr. de 2025

Respondida:

el 5 de Jun. de 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by