Scientific Computing & Visualization
Help Contact
About Accounts Computation Visualization Documentation Services

Introduction to MATLAB

Low-level Graphic Commands

Typically, MATLAB's high-level graphic commands are sufficient to produce graphs to the user's requirements. However, there are circumstances in which the user may find it necessary to modify MATLAB's settings to achieve desired results. The key commands that you will find useful to this end are:

>> handle = gca -- get current axes handle
>> handle = gcf -- get current figure handle
>> set(handle,'SomeProperty','SomeValue') -- set specific axes or figure properties (of axes/figure handle)
A list of the properties of axes or figure is produced by:
>> get(handle) -- gets a list of current property settings of handle
>> set(handle) -- gives a list of default property settings of handle
Here is an example:
>> figure  
>> t = 0:pi/100:2*pi;  
>> y = sin(t);  
>> y2 = sin(t-0.5);  
>> hold on   
>> h1 = plot(t,y)    

h1 =

     2.0015    

>> h2 = plot(t,y2)    

unknown

>> get(h2)    
       Color = [0 0 1]          
       EraseMode = normal          
       LineStyle = -          
       LineWidth = [0.5]          
       Marker = none          
       MarkerSize = [6]          
       MarkerEdgeColor = auto          
       MarkerFaceColor = none          
       XData = [ (1 by 201) double array]          
       YData = [ (1 by 201) double array]          
       ZData = []            
       
       ButtonDownFcn =           
       Children = []          
       Clipping = on          
       CreateFcn =           
       DeleteFcn =           
       BusyAction = queue          
       HandleVisibility = on          
       HitTest = on          
       Interruptible = on          
       Parent = [1.00293]          
       Selected = off          
       SelectionHighlight = on          
       Tag =           
       Type = line          
       UIContextMenu = []          
       UserData = []          
       Visible = on    
       
>> set(h2,'color',[1 0 0])  
>>  
unknown
>> set(h2,'color',[1 0 0])  
>> h3 = title('Low level graphic commands demo')    

h3 =    

    4.0016    
unknown
>> set(h3)   
       Color          
       EraseMode: [ {normal} | background | xor | none ]
       Editing: [ on | off ]
       FontAngle: [ {normal} | italic | oblique ] 
       FontName          
       FontSize          
       FontUnits: [ inches | centimeters | normalized | {points} | pixels ]
       FontWeight: [ light | {normal} | demi | bold ]          
       HorizontalAlignment: [ {left} | center | right ]          
       Position          
       Rotation          
       String          
       Units: [ inches | centimeters | normalized | points | pixels | characters | {data} ]
       Interpreter: [ {tex} | none ]          
       VerticalAlignment: [ top | cap | {middle} | baseline | bottom ]            
       
       ButtonDownFcn          
       Children          
       Clipping: [ {on} | off ]          
       CreateFcn          
       DeleteFcn          
       BusyAction: [ {queue} | cancel ]          
       HandleVisibility: [ {on} | callback | off ]          
       HitTest: [ {on} | off ]          
       Interruptible: [ {on} | off ]          
       Parent          
       Selected: [ on | off ]          
       SelectionHighlight: [ {on} | off ]          
       Tag          
       UIContextMenu          
       UserData          
       Visible: [ {on} | off ]   
       
>> get(h3)            
       Color = [0 0 0]          
       EraseMode = normal          
       Editing = off          
       Extent = [1.87097 1.01754 3.20968 0.0994152]          
       FontAngle = normal          
       FontName = Helvetica          
       FontSize = [10]          
       FontUnits = points          
       FontWeight = normal          
       HorizontalAlignment = center          
       Position = [3.49192 1.03519 17.3205]          
       Rotation = [0]          
       String = Low level graphic commands demo          
       Units = data          
       Interpreter = tex          
       VerticalAlignment = bottom            
       
       ButtonDownFcn =           
       Children = []          
       Clipping = off          
       CreateFcn =           
       DeleteFcn =           
       BusyAction = queue          
       HandleVisibility = off          
       HitTest = on          
       Interruptible = on          
       Parent = [1.00293]          
       Selected = off          
       SelectionHighlight = on          
       Tag =           
       Type = text          
       UIContextMenu = []          
       UserData = []          
       Visible = on    
       
>> set(h3,'fontsize',15)  
unknown

unknown

Documentation
Boston University
Boston University
 
OIT | CCS | July 7, 2009  
Scientific Computing & Visualization Boston University home page Boston University home page