I am using the patch function and I am trying to set a FaceColor in 2017a and nothing is working. Does anyone have any suggestions?
24 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
rtn
am 13 Okt. 2017
Bearbeitet: Walter Roberson
am 16 Okt. 2017
p = patch(px,py,1);
get(p)
set(p,'FaceColor','b')
drawnow
p.FaceAlpha = 1;
drawnow
0 Kommentare
Akzeptierte Antwort
Prashant Arora
am 16 Okt. 2017
Hi Rashida,
The reason you are seeing this behavior is because MATLAB could not create a face given vertices coordinates as "px,py". This is why you are observing no affect by changing the FaceColor.
As an example, check the following code:
r = 1;
theta = 0:pi/100:2*pi;
x = r*cos(theta);
y = r*sin(theta);
p = patch(x,y,1);
set(p ,'FaceColor', 'r')
If you have information about which vertices should be connected to form a face, you should use the patch in the following manner:
v = [0 0; 1 0; 1 1; 0 1];
f = [1 2 3 4];
patch('Faces',f,'Vertices',v,'FaceColor','red');
Here the variable f defines that MATLAB should connect vertices 1->2->3->4 to create a face. Here 2 refers to the second row of variable v and so on.
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!