Graphics |
Example -- Creating Graphics Objects
This code evaluates a mathematical function and creates three graphics objects using the property values specified as arguments to the figure
, axes
, and surface
commands. MATLAB uses default values for all other properties.
[x,y] =meshgrid
([-2:.4:2]); Z = x.*exp(-x.^2-y.^2); fh =figure
('Position',[350 275 400 300],'Color','w'); ah =axes
('Color',[.8 .8 .8],'XTick',[-2 -1 0 1 2],... 'YTick',[-2 -1 0 1 2]); sh =surface
('XData',x,'YData',y,'ZData',Z,... 'FaceColor',get(ah,'Color')+.1,... 'EdgeColor','k','Marker','o',... 'MarkerFaceColor',[.5 1 .85]);
Note that the surface
function does not use a 3-D view like the high-level surf
functions. Object creation functions simply add new objects to the current axes without changing axes properties, except the Children
property, which now includes the new object and the axis limits (XLim
, YLim
, and ZLim
), if necessary.
You can change the view using the camera commands or use the view
command.
Graphics Object Creation Functions | Parenting |