![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/557072/image.png)
Cannot use 'interp' for 'FaceColor' in patch
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nguyen Van Hieu
am 20 Mär. 2021
Kommentiert: darova
am 21 Mär. 2021
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/556552/image.png)
I want to have smoother colormap but the program said:
"Warning: Error creating or updating Patch
Error in value of property FaceVertexCData
Number of colors must equal number of vertices ".
The data are given in attached file. Please kindly help me!
s=patch(X,Y,E_t,'FaceColor','interp');
1 Kommentar
darova
am 21 Mär. 2021
Can you exaplain what your data represents?
s = load('plate.mat');
x = s.X;
y = s.Y;
z = s.E_t;
patch(x,y,z,'facecolor','interp')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/557072/image.png)
Each vertex should have it's own color
Akzeptierte Antwort
DGM
am 21 Mär. 2021
Your patch plot only has three colors, because your CData vector E_t only contains three unique values. Maybe that's the result of some prior nearest-neighbor interpolation process that could be made continuous? I don't know exactly what your CData values mean in-context, but are you sure you're not expecting to obtain something like this?
% try to return stepped CData to a smooth linear ramp
CD=interp1([1 13 25],unique(E_t)',1:36,'linear','extrap');
s=patch(X,Y,CD,'FaceColor','flat');
Why it's complaining about the 'interp' mode, I'm not sure. If you really need to use 'interp' mode, that question will need to be addressed.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Polygons finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!