MATLAB Function Reference (Volume 2: Graphics)

MATLAB Function Reference (Volume 2: Graphics) MATLAB Function Reference (Volume 2: Graphics)

12.07.2015 Views

axesExamplesZoomingZoom in using aspect ratio and limits:sphereset(gca,'DataAspectRatio',[1 1 1],...'PlotBoxAspectRatio',[1 1 1],'ZLim',[−0.6 0.6])Zoom in and out using the CameraViewAngle:sphereset(gca,'CameraViewAngle',get(gca,'CameraViewAngle')−5)set(gca,'CameraViewAngle',get(gca,'CameraViewAngle')+5)Note that both examples disable MATLAB’s stretch-to-fill behavior.Positioning the AxesThe axes Position property enables you to define the location of the axeswithin the figure window. For example,h = axes('Position',position_rectangle)creates an axes object at the specified position within the current figure andreturns a handle to it. Specify the location and size of the axes with a rectangledefined by a four-element vector,position_rectangle = [left, bottom, width, height];The left and bottom elements of this vector define the distance from thelower-left corner of the figure to the lower-left corner of the rectangle. Thewidth and height elements define the dimensions of the rectangle. You specifythese values in units determined by the Units property. By default, MATLABuses normalized units where (0,0) is the lower-left corner and (1.0,1.0) is theupper-right corner of the figure window.You can define multiple axes in a single figure window:axes('position',[.1 .1 .8 .6])mesh(peaks(20));axes('position',[.1 .7 .8 .2])pcolor([1:10;1:10]);2-6

axesIn this example, the first plot occupies the bottom two-thirds of the figure, andthe second occupies the top third.21.511 2 3 4 5 6 7 8 9 101050−5−102015105005101520See Alsoaxis, cla, clf, figure, gca, grid, subplot, title, xlabel, ylabel, zlabel,viewObjectHierarchy2-7

axesExamplesZoomingZoom in using aspect ratio and limits:sphereset(gca,'DataAspectRatio',[1 1 1],...'PlotBoxAspectRatio',[1 1 1],'ZLim',[−0.6 0.6])Zoom in and out using the CameraViewAngle:sphereset(gca,'CameraViewAngle',get(gca,'CameraViewAngle')−5)set(gca,'CameraViewAngle',get(gca,'CameraViewAngle')+5)Note that both examples disable <strong>MATLAB</strong>’s stretch-to-fill behavior.Positioning the AxesThe axes Position property enables you to define the location of the axeswithin the figure window. For example,h = axes('Position',position_rectangle)creates an axes object at the specified position within the current figure andreturns a handle to it. Specify the location and size of the axes with a rectangledefined by a four-element vector,position_rectangle = [left, bottom, width, height];The left and bottom elements of this vector define the distance from thelower-left corner of the figure to the lower-left corner of the rectangle. Thewidth and height elements define the dimensions of the rectangle. You specifythese values in units determined by the Units property. By default, <strong>MATLAB</strong>uses normalized units where (0,0) is the lower-left corner and (1.0,1.0) is theupper-right corner of the figure window.You can define multiple axes in a single figure window:axes('position',[.1 .1 .8 .6])mesh(peaks(20));axes('position',[.1 .7 .8 .2])pcolor([1:10;1:10]);2-6

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!