MATLAB: How to make 2D rainbow

2dMATLABplot

How to make a 2D rainbow plot like
https://en.wikipedia.org/wiki/Visible_spectrum#/media/File:Spectrum.svg https://en.wikipedia.org/wiki/Visible_spectrum#/media/File:Spectrum.svg
This will make 1D line.
x=1:10; y = [2 2 2 2 2 2 2 2 2 2];length = size(x, 2);
d = length:-1:1;
p = patch([x ],[y ], [d ], 'EdgeColor', 'interp');
axis off
How to add the second dimension?

Best Answer

x=1:10; y = [2 2 2 2 2 2 2 2 2 2];length = size(x, 2);
d = length:-1:1;
p = patch([x ],[y ], [d ], 'EdgeColor', 'interp','Linewidth',20);