Why does "patch(X,Y,Z, FaceColor=C)" result in thin lines rather than full patches?
10 views (last 30 days)
Show older comments
MathWorks Support Team
on 31 Oct 2025 at 0:00
Answered: MathWorks Support Team
on 31 Oct 2025 at 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?
Accepted Answer
MathWorks Support Team
on 31 Oct 2025 at 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 Comments
More Answers (0)
See Also
Categories
Find more on Polygons in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!