Vim
Vim

Reputation: 1518

In Matlab patch plot, can I recolour a specific face of the polyhedron?

I want to recolour a specific face (say the first) in the following patch plot so it has a different colour from all the other faces. Here's the code for the polyhedron:

clear;
faces = [1     3     5
         2     4     6
         1     3     6
         2     4     5
         1     4     5
         2     3     6
         1     4     6
         2     3     5];

vert = [8.6288   -1.4930    0.1330
       -8.6288    1.4930   -0.1330
       -1.6879   -4.9352   -6.3458
        1.6879    4.9352    6.3458
        2.9250    7.1153   -4.6262
       -2.9250   -7.1153    4.6262];

clf
axes();
xlabel('x');
ylabel('y');
zlabel('z');
patch('vertices',vert,'faces',faces, 'facecolor','blue', 'facealpha', 0.4);

And the patch plot it gives:

enter image description here

Unfortunately, due to lack of working examples of color map provided in the patch properties documentation, I really have no idea how to do it.

Could anybody help me? Thanks!

Upvotes: 0

Views: 360

Answers (1)

Hazem
Hazem

Reputation: 380

hold on
faces2 = [1     3     5]; % the face you want to recolor
patch('vertices',vert,'faces',faces2, 'facecolor','red', 'facealpha', 0.4);

enter image description here

Upvotes: 1

Related Questions