2、获取 坐标轴 对象属性
使用 get(gca) 可以获取当前坐标轴对象的属性 ;
代码示例 :
% x 轴变量 % 在 0 ~ 2pi 之间产生 1000 个数值 x = linspace(0, 2 * pi, 1000); % y 轴变量 y = sin(x); % 使用 h 变量接受 plot 函数绘制的曲线图像句柄值 h = plot(x, y); % 获取曲线图像的属性 %get(h) % 获取坐标轴对象属性 get(gca)
绘制结果 :
命令行窗口输出结果 : 其中 XLim: [0 7] 表示 x xx 轴取值范围是 0 00 ~ 7 77 ;
>> Untitled2 ALim: [0 1] ALimMode: 'auto' ActivePositionProperty: 'outerposition' AmbientLightColor: [1 1 1] BeingDeleted: 'off' Box: 'on' BoxStyle: 'back' BusyAction: 'queue' ButtonDownFcn: '' CLim: [0 1] CLimMode: 'auto' CameraPosition: [3.5000 0 17.3205] CameraPositionMode: 'auto' CameraTarget: [3.5000 0 0] CameraTargetMode: 'auto' CameraUpVector: [0 1 0] CameraUpVectorMode: 'auto' CameraViewAngle: 6.6086 CameraViewAngleMode: 'auto' Children: [1×1 Line] Clipping: 'on' ClippingStyle: '3dbox' Color: [1 1 1] ColorOrder: [7×3 double] ColorOrderIndex: 2 CreateFcn: '' CurrentPoint: [2×3 double] DataAspectRatio: [3.5000 1 1] DataAspectRatioMode: 'auto' DeleteFcn: '' FontAngle: 'normal' FontName: 'Helvetica' FontSize: 10 FontSmoothing: 'on' FontUnits: 'points' FontWeight: 'normal' GridAlpha: 0.1500 GridAlphaMode: 'auto' GridColor: [0.1500 0.1500 0.1500] GridColorMode: 'auto' GridLineStyle: '-' HandleVisibility: 'on' HitTest: 'on' Interruptible: 'on' LabelFontSizeMultiplier: 1.1000 Layer: 'bottom' Legend: [0×0 GraphicsPlaceholder] LineStyleOrder: '-' LineStyleOrderIndex: 1 LineWidth: 0.5000 MinorGridAlpha: 0.2500 MinorGridAlphaMode: 'auto' MinorGridColor: [0.1000 0.1000 0.1000] MinorGridColorMode: 'auto' MinorGridLineStyle: ':' NextPlot: 'replace' OuterPosition: [0 0 1 1] Parent: [1×1 Figure] PickableParts: 'visible' PlotBoxAspectRatio: [1 0.7903 0.7903] PlotBoxAspectRatioMode: 'auto' Position: [0.1300 0.1100 0.7750 0.8150] Projection: 'orthographic' Selected: 'off' SelectionHighlight: 'on' SortMethod: 'childorder' Tag: '' TickDir: 'in' TickDirMode: 'auto' TickLabelInterpreter: 'tex' TickLength: [0.0100 0.0250] TightInset: [0.0506 0.0532 0.0071 0.0202] Title: [1×1 Text] TitleFontSizeMultiplier: 1.1000 TitleFontWeight: 'normal' Type: 'axes' UIContextMenu: [0×0 GraphicsPlaceholder] Units: 'normalized' UserData: [] View: [0 90] Visible: 'on' XAxis: [1×1 NumericRuler] XAxisLocation: 'bottom' XColor: [0.1500 0.1500 0.1500] XColorMode: 'auto' XDir: 'normal' XGrid: 'off' XLabel: [1×1 Text] XLim: [0 7] XLimMode: 'auto' XMinorGrid: 'off' XMinorTick: 'off' XScale: 'linear' XTick: [0 1 2 3 4 5 6 7] XTickLabel: {8×1 cell} XTickLabelMode: 'auto' XTickLabelRotation: 0 XTickMode: 'auto' YAxis: [1×1 NumericRuler] YAxisLocation: 'left' YColor: [0.1500 0.1500 0.1500] YColorMode: 'auto' YDir: 'normal' YGrid: 'off' YLabel: [1×1 Text] YLim: [-1 1] YLimMode: 'auto' YMinorGrid: 'off' YMinorTick: 'off' YScale: 'linear' YTick: [-1 -0.8000 -0.6000 -0.4000 -0.2000 0 0.2000 0.4000 0.6000 0.8000 1] YTickLabel: {11×1 cell} YTickLabelMode: 'auto' YTickLabelRotation: 0 YTickMode: 'auto' ZAxis: [1×1 NumericRuler] ZColor: [0.1500 0.1500 0.1500] ZColorMode: 'auto' ZDir: 'normal' ZGrid: 'off' ZLabel: [1×1 Text] ZLim: [-1 1] ZLimMode: 'auto' ZMinorGrid: 'off' ZMinorTick: 'off' ZScale: 'linear' ZTick: [-1 0 1] ZTickLabel: '' ZTickLabelMode: 'auto' ZTickLabelRotation: 0 ZTickMode: 'auto' >>