# bug #65457: Patch: octave and MATLAB interpret ambiguous patch(x,y,C) cases differently

 Submitter: Nicholas Jankowski Submitted: Tue 12 Mar 2024 09:56:55 PM UTC Category: Plotting Severity: 2 - Minor Priority: 5 - Normal Item Group: Matlab Compatibility Status: Confirmed Assigned to: None Originator Name: Open/Closed:  * Open Release:  * dev Operating System:  * Any Fixed Release: None Planned Release: None
* Mandatory Fields

Add a New Comment Rich Markup

## Discussion

Wed 13 Mar 2024 12:54:10 PM UTC, comment #3:

also, for the ones that produce an error, that only occurs if they are floating point values based on how it interprets rgb colors.

hp = patch ([x1,x2,x1], [y1,y2,y2], int32([1 2 3]))
# plots three identically gray faces

hp = patch ([x1,x2,x1], [y1,y2,y2], int32([1 2 3])')
# plots 3 faces each a different (same result as type double)
+verbatim

Nicholas Jankowski <nrjank>
Wed 13 Mar 2024 12:50:32 PM UTC, comment #2:

sorry, that should have said:

hp = patch ([x1,x2,x1], [y1,y2,y2], [1 2 3]) # c is row vector
Error using patch
Invalid RGB triplet. Specify a three-element vector of values between 0 and 1.

hp = patch ([x1,x2,x1], [y1,y2,y2], [1 2 3]') # c is column vector
#  plots 3 faces each a different color.

Nicholas Jankowski <nrjank>
Wed 13 Mar 2024 07:52:50 AM UTC, comment #1:

In comment #0, the command `hp = patch ([x1,x2,x1], [y1,y2,y2], [1 2 3])` appears twice with different annotations about its result in Matlab R2023b.
Could you please clarify which is the expected result?

Markus Mützel <mmuetzel>
Tue 12 Mar 2024 09:56:55 PM UTC, original submission:

as per the bug #65431 report, when patch is called with the patch(x,y,C) form, ambiguous forms of C are interpreted differently in Octave vs Matlab.  Octave interprets all of the cases below as 1-color-per-face over 3 faces, while MATLAB interprets some as 1 RGB color spec for all three faces and errors on a few others.

x1 = [1 2 3]';
x2 = [4 5 6]';
y1 = [0 1 0]';
y2 = [2 3 2]';

matlab 2023b

hp = patch ([x1,x2,x1], [y1,y2,y2], [0 1 0])
# plots 3 green faces

hp = patch ([x1,x2,x1], [y1,y2,y2], [0 1 0]')
# plots 3 faces each a different color

hp = patch ([x1,x2,x1], [y1,y2,y2], reshape([0 1 0],1,1,3))
# plots 3 green faces

hp = patch ([x1,x2,x1], [y1,y2,y2], [1 2 3])
Error using patch
Invalid RGB triplet. Specify a three-element vector of values between 0 and 1.

hp = patch ([x1,x2,x1], [y1,y2,y2], [1 2 3])
#  plots 3 faces each a different color.

hp = patch ([x1,x2,x1], [y1,y2,y2], reshape([1 2 3],1,1,3))
Error using patch
Invalid RGB triplet. Specify a three-element vector of values between 0 and 1.

hp = patch ([x1,x2,x1], [y1,y2,y2], [.1 .2 .3])
#  plots 3 faces all the same color.

hp = patch ([x1,x2,x1], [y1,y2,y2], [.1 .2 .3]')
#  plots 3 faces each a different color.

hp = patch ([x1,x2,x1], [y1,y2,y2], reshape([.1 .2 .3],1,1,3))
#  plots 3 faces all the same color.

Octave:

hp = patch ([x1,x2,x1], [y1,y2,y2], [0 1 0])
hp = patch ([x1,x2,x1], [y1,y2,y2], [0 1 0]')
hp = patch ([x1,x2,x1], [y1,y2,y2], reshape([1 2 3],0 ,1,0))
## plots three faces, 2 dark one light.

hp = patch ([x1,x2,x1], [y1,y2,y2], [1 2 3])
hp = patch ([x1,x2,x1], [y1,y2,y2], [1 2 3]')
hp = patch ([x1,x2,x1], [y1,y2,y2], reshape([1 2 3],1,1,3))
hp = patch ([x1,x2,x1], [y1,y2,y2], [.1 .2 .3])
hp = patch ([x1,x2,x1], [y1,y2,y2], [.1 .2 .3]')
hp = patch ([x1,x2,x1], [y1,y2,y2], reshape([.1 .2 .3],1,1,3))
# each plots 3 faces each a different color.

Nicholas Jankowski <nrjank>

## Attached Files

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Comment:

No files currently attached

## Dependencies

Depends on the following items

Digest:
bug dependencies.

Items that depend on this one: None found

## Mail Notification Carbon-Copy List

Carbon-Copy List
• -email is unavailable- added by mmuetzel (Posted a comment)
• -email is unavailable- added by nrjank (Submitted the item)
•

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only group members can vote.

## History

Follow 3 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2024-03-12 nrjank SummaryPatch: octave and MATLAB interpret ambiguous patch(x,y,C) case differently Patch: octave and MATLAB interpret ambiguous patch(x,y,C) cases differently
2024-03-12 nrjank StatusNone Confirmed
Dependencies- Depends on bugs #65431