how can I change the distance between the axis and their title?
    54 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Mohammad
 el 21 de En. de 2014
  
    
    
    
    
    Comentada: AJ von Alt
    
 el 21 de En. de 2014
            I want to change the distance between the axis and their title in a figure. is it possible?
0 comentarios
Respuesta aceptada
Más respuestas (1)
  AJ von Alt
    
 el 21 de En. de 2014
        
      Editada: AJ von Alt
    
 el 21 de En. de 2014
  
      A title is a text object. You can change the position of any text object by using set to change the object's 'position' property value to a new vector. See the text properties documentation for more information.
Here is a quick demo where the title is moved to the left portion of the figure.
% move a title to the left
% create a figure and plot something
figure(1);
line;
% create a title and store its handle
th = title('blah');
% get the position of the title
titlePos = get( th , 'position');
% change the x value  to 0
titlePos(1) = 0;
% update the position
set( th , 'position' , titlePos);
2 comentarios
  AJ von Alt
    
 el 21 de En. de 2014
				Those commands are changing the position of the axes object, not the title.
If you want to change the title object, you need to use the title handle as the first argument to set, not the axes handle.
Setting units to centimeters and changing the position by 0.2 mm doesn't do much. That is a really really small change. Unless you have a good reason to use centimeter units, I would recommend sticking with normalized units. Normalized units are much more intuitive. (0,0) is at the bottom left of the figure and (1,1) is at the top of the figure. An object at [0.25 0.5 1] would be 1/4 of the way from the left and 1/2 way from the bottom.
Try this code to give you an idea of how to modify the title position.
set(gca,'Units','normalized')
titleHandle = get( gca ,'Title' );
pos  = get( titleHandle , 'position' );
pos1 = pos - [0 0.05 0] 
set( titleHandle , 'position' , pos1 );
Ver también
Categorías
				Más información sobre Title en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


