Why does "patch(X,Y,Z, FaceColor=C)" result in thin lines rather than full patches?
조회 수: 10 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2025년 10월 31일 0:00
답변: MathWorks Support Team
2025년 10월 31일 18:35
When calling "patch" with the following syntax:
>> patch(X, Y, Z, 'FaceColor', C)
MATLAB interprets "Z" as the color, and displays straight lines rather than the full patches.
Why does this happen?
채택된 답변
MathWorks Support Team
2025년 10월 31일 0:00
This behavior is expected. MATLAB expects all positional arguments to come before Name-Value arguments. You can either call "patch" and specific a color by using:
>> patch(X,Y,Z,C)
or
>> patch('XData', X, 'YData', Y, 'ZData', Z, 'FaceColor', C)
The problem with the following code
>> patch(input1, input2, input3, 'FaceColor', input4) % (the incorrect syntax resulting in thin lines)
is that the arguments are interpreted by MATLAB as
>> patch(X, Y, C, 'FaceColor', C)
"input3" being interpreted as "C" since MATLAB expects either the positional arguments (X,Y,Z,C) or (X,Y,C) before Name-Value arguments when using the syntax "patch(___, Name, Value)". There is no (X,Y,Z) syntax that can precede the Name-Value arguments.
Please refer to the documentation on "patch" for more details.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Polygons에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!