
Why isn't the progress bar in the center of the waitbar after setting the position?
    10 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Albert Bing
      
 el 21 de Dic. de 2019
  
    
    
    
    
    Comentada: Nadatimuj
      
 el 26 de Sept. de 2023
            For some reason I wanted to change the position of the waitbar. But the progress bar was not in the center anymore. Any suggestions?
waitbar(0, 'processing', 'Name', 'title',...
    'Units', 'normalized', 'Position', [0.18 0.43 0.23 0.08]);

0 comentarios
Respuesta aceptada
  Stephen23
      
      
 el 21 de Dic. de 2019
        
      Editada: Stephen23
      
      
 el 21 de Dic. de 2019
  
      The designer of the inbuilt waitbar used a fixed absolute size for the bar's axes, defined in points. Apparently they did not consider that users might want to change the figure size and have the bar automaticallly adjust to suit... everything in that function is written assuming a fixed-size non-dockable figure.
You can easily change the bar's axes's units:
>> h = waitbar(0.5);
>> set(get(h,'children'),'units','normalized')
and then adjust the figure size afterwards:
>> set(h, 'Units', 'normalized', 'Position', [0.18,0.43,0.23,0.08])

As an alternative, it is not very difficult to write your own waitbar/progress bar: define a figure with axes containing a patch object, adjust the patch width.
You can also find plenty of waitbar submissions on FEX, some might have normalized axes too:
1 comentario
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!