更改坐标轴属性 您所在的位置:网站首页 matlab设置坐标名称 更改坐标轴属性

更改坐标轴属性

2022-05-13 21:07| 来源: 网络整理| 查看: 265

坐标轴对象

所有绘图都包含在一套坐标轴内。

x = linspace(0,12); y = 10*exp(-0.65*x); figure plot(x,y)

gca 函数返回当前图形的当前坐标轴。与所有图形对象一样,坐标轴有您可以查看和修改的属性。这些属性具有默认值。下面所示的坐标轴对象 ax 显示了最常用的坐标轴属性,如 XLim、YLimXScale 和 YScale。

ax = gca ax = Axes with properties: XLim: [0 12] YLim: [0 10] XScale: 'linear' YScale: 'linear' GridLineStyle: '-' Position: [0.1300 0.1100 0.7750 0.8150] Units: 'normalized' Use GET to show all properties 获取个别坐标轴属性

若要访问个别属性,请使用圆点表示法语法 object.PropertyName。例如,返回 x 轴范围。

ax.XLim ans = 0 12 更改常用的坐标轴属性

有些函数可用于更改坐标轴属性。例如,使用 axis 函数更改坐标轴的缩放和外观。

axis square

使用 xlim、ylim 和 zlim 函数更改坐标轴范围。

xlim([0 10])

使用 xlabel、ylabel 和 zlabel 函数为坐标轴添加标签。

xlabel('x') ylabel('exp(x)')

更改其他坐标轴属性

若要自定义坐标轴的外观,请使用圆点表示法语法 object.PropertyName 更改其属性值。

ax.YScale = 'log'; % set y-axis to logarithmic scaling ax.FontSize = 12; % set font size for axes labels ax.XGrid = 'on'; % draw gridlines perpendicular to x-axis ax.YGrid = 'on'; % draw gridlines perpendicular to y-axis

获取所有坐标轴属性

MATLAB 中的图形对象有许多属性。若要查看对象的所有属性,请使用 get 命令。

get(ax) 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: [5 5.0050 17.3205] CameraPositionMode: 'auto' CameraTarget: [5 5.0050 0] CameraTargetMode: 'auto' CameraUpVector: [0 1 0] CameraUpVectorMode: 'auto' CameraViewAngle: 6.6086 CameraViewAngleMode: 'auto' Children: [1x1 Line] Clipping: 'on' ClippingStyle: '3dbox' Color: [1 1 1] ColorOrder: [7x3 double] ColorOrderIndex: 2 CreateFcn: '' CurrentPoint: [2x3 double] DataAspectRatio: [5 4.9950 1] DataAspectRatioMode: 'auto' DeleteFcn: '' FontAngle: 'normal' FontName: 'Helvetica' FontSize: 12 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' 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: [1x1 Figure] PickableParts: 'visible' PlotBoxAspectRatio: [1 1 1] PlotBoxAspectRatioMode: 'manual' 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.0093 0.0943 0 0.0226] Title: [1x1 Text] TitleFontSizeMultiplier: 1.1000 TitleFontWeight: 'bold' Type: 'axes' UIContextMenu: [0x0 GraphicsPlaceholder] Units: 'normalized' UserData: [] View: [0 90] Visible: 'on' XAxis: [1x1 NumericRuler] XAxisLocation: 'bottom' XColor: [0.1500 0.1500 0.1500] XColorMode: 'auto' XDir: 'normal' XGrid: 'on' XLabel: [1x1 Text] XLim: [0 10] XLimMode: 'manual' XMinorGrid: 'off' XMinorTick: 'off' XScale: 'linear' XTick: [0 2 4 6 8 10] XTickLabel: {6x1 cell} XTickLabelMode: 'auto' XTickLabelRotation: 0 XTickMode: 'auto' YAxis: [1x1 NumericRuler] YAxisLocation: 'left' YColor: [0.1500 0.1500 0.1500] YColorMode: 'auto' YDir: 'normal' YGrid: 'on' YLabel: [1x1 Text] YLim: [0.0100 10] YLimMode: 'auto' YMinorGrid: 'on' YMinorTick: 'off' YScale: 'log' YTick: [0.0100 0.1000 1 10] YTickLabel: {4x1 cell} YTickLabelMode: 'auto' YTickLabelRotation: 0 YTickMode: 'auto' ZAxis: [1x1 NumericRuler] ZColor: [0.1500 0.1500 0.1500] ZColorMode: 'auto' ZDir: 'normal' ZGrid: 'off' ZLabel: [1x1 Text] ZLim: [-1 1] ZLimMode: 'auto' ZMinorGrid: 'off' ZMinorTick: 'off' ZScale: 'linear' ZTick: [-1 0 1] ZTickLabel: '' ZTickLabelMode: 'auto' ZTickLabelRotation: 0 ZTickMode: 'auto'



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有