Main Content

surface 속성 변경

이 예제에서는 MATLAB®에서 곡면 플롯의 속성을 가져오고 속성값을 변경하여 플롯을 사용자 지정하는 방법을 보여줍니다.

surface 객체

MATLAB에서 surface 객체를 생성하는 방법에는 여러 가지가 있습니다. 그중 하나는 surf를 사용하는 방법입니다.

[X,Y,Z] = peaks(50);

figure
surf(X,Y,Z)

Figure contains an axes object. The axes object contains an object of type surface.

모든 그래픽스 객체와 마찬가지로, surface는 속성을 가지며, 사용자는 이러한 속성을 확인하거나 수정할 수 있습니다. 이러한 속성은 디폴트 값을 가집니다. surface 객체 s를 표시하면 EdgeColor, LineStyle, FaceColor, FaceLighting 등과 같이 가장 일반적으로 사용되는 surface 속성을 볼 수 있습니다.

s = surf(X,Y,Z)

Figure contains an axes object. The axes object contains an object of type surface.

s = 
  Surface with properties:

       EdgeColor: [0 0 0]
       LineStyle: '-'
       FaceColor: 'flat'
    FaceLighting: 'flat'
       FaceAlpha: 1
           XData: [50x50 double]
           YData: [50x50 double]
           ZData: [50x50 double]
           CData: [50x50 double]

  Use GET to show all properties

개별 surface 속성 가져오기

개별 속성에 액세스하려면 점 표기법 구문 object.PropertyName을 사용하십시오. 예를 들어, 다음 명령은 surface의 FaceColor 속성을 반환합니다.

s.FaceColor
ans = 
'flat'

일반적으로 사용되는 surface 속성 변경

여러 가지 함수를 사용하여 surface 속성을 변경할 수 있습니다. 예를 들어, shading 함수를 사용하여 곡면의 음영을 제어할 수 있습니다.

shading interp    % interpolate the colormap across the surface face

Figure contains an axes object. The axes object contains an object of type surface.

lighting 함수를 사용하여 곡면의 조명 특성을 조정합니다. lighting이 영향을 미치려면 light 객체를 만들어 곡면을 비춰야 합니다.

light               % create a light
lighting gouraud    % preferred method for lighting curved surfaces

Figure contains an axes object. The axes object contains an object of type surface.

곡면의 반사율 속성을 변경하려면 material 함수를 사용하십시오.

material dull    % set material to be dull, no specular highlights

Figure contains an axes object. The axes object contains an object of type surface.

현재 좌표축(Current Axes)에 있는 모든 객체의 투명도를 설정하려면 alpha 함수를 사용하십시오. 이 함수는 투명도를 1과 0 사이의 값으로 설정합니다. 여기서 1은 완전히 불투명함을 의미하고 0은 완전히 투명함을 의미합니다.

alpha(0.8)    % set transparency to 0.8

Figure contains an axes object. The axes object contains an object of type surface.

다른 surface 속성 변경

곡면 모양을 사용자 지정하려면 점 표기법을 사용하여 속성값을 변경하십시오.

CData는 곡면의 꼭짓점 색을 정의합니다. FaceColor 속성은 꼭짓점 색으로부터 곡면의 색을 결정하는 방식을 나타냅니다.

s.CData = hypot(X,Y);      % set color data

Figure contains an axes object. The axes object contains an object of type surface.

s.FaceColor = 'interp';    % interpolate to get face colors

AlphaData는 곡면의 각 꼭짓점에 대한 투명도를 정의합니다. FaceAlpha 속성은 꼭짓점 투명도로부터 곡면의 투명도를 결정하는 방식을 나타냅니다.

s.AlphaData = gradient(Z);    % set vertex transparencies
s.FaceAlpha = 'interp';       % interpolate to get face transparencies

Figure contains an axes object. The axes object contains an object of type surface.

모든 surface 속성 가져오기

MATLAB의 그래픽스 객체는 많은 속성을 가지고 있습니다. surface의 모든 속성을 보려면 get 명령을 사용하십시오.

get(s)
          AlignVertexCenters: off
                   AlphaData: [50x50 double]
            AlphaDataMapping: 'scaled'
             AmbientStrength: 0.3000
                  Annotation: [1x1 matlab.graphics.eventdata.Annotation]
            BackFaceLighting: 'reverselit'
                BeingDeleted: off
                  BusyAction: 'queue'
               ButtonDownFcn: ''
                       CData: [50x50 double]
                CDataMapping: 'scaled'
                   CDataMode: 'manual'
                 CDataSource: ''
                    Children: [0x0 GraphicsPlaceholder]
                    Clipping: on
                 ContextMenu: [0x0 GraphicsPlaceholder]
                   CreateFcn: ''
             DataTipTemplate: [1x1 matlab.graphics.datatip.DataTipTemplate]
                   DeleteFcn: ''
             DiffuseStrength: 0.8000
                 DisplayName: ''
                   EdgeAlpha: 1
                   EdgeColor: 'none'
                EdgeLighting: 'none'
                   FaceAlpha: 'interp'
                   FaceColor: 'interp'
                FaceLighting: 'gouraud'
                 FaceNormals: [49x49x3 double]
             FaceNormalsMode: 'auto'
            HandleVisibility: 'on'
                     HitTest: on
               Interruptible: on
                   LineStyle: '-'
                   LineWidth: 0.5000
                      Marker: 'none'
             MarkerEdgeColor: 'auto'
             MarkerFaceColor: 'none'
                  MarkerSize: 6
                   MeshStyle: 'both'
                      Parent: [1x1 Axes]
               PickableParts: 'visible'
                    Selected: off
          SelectionHighlight: on
    SpecularColorReflectance: 1
            SpecularExponent: 10
            SpecularStrength: 0
                         Tag: ''
                        Type: 'surface'
                    UserData: []
               VertexNormals: [50x50x3 double]
           VertexNormalsMode: 'auto'
                     Visible: on
                       XData: [50x50 double]
                   XDataMode: 'manual'
                 XDataSource: ''
                       YData: [50x50 double]
                   YDataMode: 'manual'
                 YDataSource: ''
                       ZData: [50x50 double]
                 ZDataSource: ''