matlab画图功能再探

摘要

复习了一下 matlab 里面的基本画图函数的属性

1
2
3
close all;
th = linspace()0,2*pi;
fig1 = plot(th,sin(th),'g',th,cos(th),'b:');

1

plot 命令返回一个标识图形目标的向量,其元素称为句柄,这些句柄可以确定目标的特性.若想知道第一条曲线的特性,输入get(fig1(1)),不要关闭Figure 1窗口.

输出

    AlignVertexCenters: off
            Annotation: [1×1 matlab.graphics.eventdata.Annotation]
          BeingDeleted: off
            BusyAction: 'queue'
         ButtonDownFcn: ''
              Children: [0×0 GraphicsPlaceholder]
              Clipping: on
                 Color: [0 1 0]
             ColorMode: 'manual'
           ContextMenu: [0×0 GraphicsPlaceholder]
             CreateFcn: ''
       DataTipTemplate: [1×1 matlab.graphics.datatip.DataTipTemplate]
             DeleteFcn: ''
           DisplayName: ''
      HandleVisibility: 'on'
               HitTest: on
         Interruptible: on
              LineJoin: 'round'
             LineStyle: '-'
         LineStyleMode: 'auto'
             LineWidth: 0.5000
                Marker: 'none'
       MarkerEdgeColor: 'auto'
       MarkerFaceColor: 'none'
         MarkerIndices: [1×100 uint64]
            MarkerMode: 'auto'
            MarkerSize: 6
                Parent: [1×1 Axes]
         PickableParts: 'visible'
              Selected: off
    SelectionHighlight: on
           SeriesIndex: 1
                   Tag: ''
                  Type: 'line'
              UserData: []
               Visible: on
                 XData: [1×100 double]
             XDataMode: 'manual'
           XDataSource: ''
                 YData: [1×100 double]
           YDataSource: ''
                 ZData: [1×0 double]
           ZDataSource: ''

若想了解第二第曲线的特性,输入get(fig1(2)),不要关闭Figure 1窗口.

输出
    AlignVertexCenters: off
            Annotation: [1×1 matlab.graphics.eventdata.Annotation]
          BeingDeleted: off
            BusyAction: 'queue'
         ButtonDownFcn: ''
              Children: [0×0 GraphicsPlaceholder]
              Clipping: on
                 Color: [0 0 1]
             ColorMode: 'manual'
           ContextMenu: [0×0 GraphicsPlaceholder]
             CreateFcn: ''
       DataTipTemplate: [1×1 matlab.graphics.datatip.DataTipTemplate]
             DeleteFcn: ''
           DisplayName: ''
      HandleVisibility: 'on'
               HitTest: on
         Interruptible: on
              LineJoin: 'round'
             LineStyle: ':'
         LineStyleMode: 'manual'
             LineWidth: 0.5000
                Marker: 'none'
       MarkerEdgeColor: 'auto'
       MarkerFaceColor: 'none'
         MarkerIndices: [1×100 uint64]
            MarkerMode: 'manual'
            MarkerSize: 6
                Parent: [1×1 Axes]
         PickableParts: 'visible'
              Selected: off
    SelectionHighlight: on
           SeriesIndex: 2
                   Tag: ''
                  Type: 'line'
              UserData: []
               Visible: on
                 XData: [1×100 double]
             XDataMode: 'manual'
           XDataSource: ''
                 YData: [1×100 double]
           YDataSource: ''
                 ZData: [1×0 double]
           ZDataSource: ''

对于图形本身,由于是第一的图形,所以句柄是1,输入get(1)

输出

                 Alphamap: [1×64 double]
             BeingDeleted: off
               BusyAction: 'queue'
            ButtonDownFcn: ''
                 Children: [1×1 Axes]
                 Clipping: on
          CloseRequestFcn: 'closereq'
                    Color: [0.9400 0.9400 0.9400]
                 Colormap: [256×3 double]
              ContextMenu: [0×0 GraphicsPlaceholder]
                CreateFcn: ''
              CurrentAxes: [1×1 Axes]
         CurrentCharacter: ''
            CurrentObject: [1×1 Line]
             CurrentPoint: [408 289]
                DeleteFcn: ''
             DockControls: on
                 FileName: '/home/pacaep/aepBlog/source/image/plot使用方法再探/1.svg'
        GraphicsSmoothing: on
         HandleVisibility: 'on'
                     Icon: ''
            InnerPosition: [200 200 600 472]
            IntegerHandle: on
            Interruptible: on
           InvertHardcopy: on
              KeyPressFcn: ''
            KeyReleaseFcn: ''
                  MenuBar: 'figure'
                     Name: ''
                 NextPlot: 'add'
                   Number: 1
              NumberTitle: on
            OuterPosition: [200 200 600 557]
         PaperOrientation: 'portrait'
            PaperPosition: [1.1250 3.0417 6.2500 4.9167]
        PaperPositionMode: 'auto'
                PaperSize: [8.5000 11]
                PaperType: 'usletter'
               PaperUnits: 'inches'
                   Parent: [1×1 Root]
                  Pointer: 'arrow'
        PointerShapeCData: [16×16 double]
      PointerShapeHotSpot: [8 8]
                 Position: [200 200 600 472]
                 Renderer: 'opengl'
             RendererMode: 'auto'
                   Resize: on
               Scrollable: off
            SelectionType: 'alt'
           SizeChangedFcn: ''
                      Tag: ''
                  ToolBar: 'auto'
                     Type: 'figure'
                    Units: 'pixels'
                 UserData: []
                  Visible: on
      WindowButtonDownFcn: ''
    WindowButtonMotionFcn: ''
        WindowButtonUpFcn: ''
        WindowKeyPressFcn: ''
      WindowKeyReleaseFcn: ''
     WindowScrollWheelFcn: ''
              WindowState: 'normal'
              WindowStyle: 'normal'
                 XDisplay: ':0'
为了解图形窗口的设置,输入`set(1)` `set(H,Name,Value)` 为 H 标识的对象指定其 Name 属性的值 从图像中删去余弦曲线,输入`delete(fig1(2))` `refresh`命令可以刷新图像. 建立一个新的图形窗口,保留前一个图形窗口,输入`H=figure`,将打开新的图形窗口并设定为活动,输入`gcf`获得当前图形的句柄.
输出

  Figure (2) - 属性:
      Number: 2
        Name: ''
       Color: [0.9400 0.9400 0.9400]
    Position: [200 200 600 472]
       Units: 'pixels'
- ETX   Thank you for reading -
  • Copyright: All posts on this blog except otherwise stated, All adopt CC BY-NC-ND 4.0 license agreement. Please indicate the source of reprint!