I'm trying to draw a truncated octahedron in MATLAB. This is also known as a permutahedron so my strategy is to link up all the vertices via adjacent transpositions of permutations in $S_4$. What I would like is this:

Here's the code:
%Size of S_n
n=4;
%Identity permutation
p=1:n;
%Matrix of Permutations as rows
Pmat=perms(p);
%Total number of perms
Nsize=factorial(n);
%Adjacency matrix=1 when two perms are linked by an adjacent transposition
Padj=zeros(Nsize,Nsize);
for i=1:(Nsize-1)
for j=(i+1):Nsize
p1=Pmat(i,:);
p2=Pmat(j,:);
for k=1:(n-1);
p1temp=p1;
p1temp(k)=p1(k+1);
p1temp(k+1)=p1(k);
if p1temp==p2
Padj(i,j)=1;
end
end
end
end
%Make it symmetric
Padj=(Padj+Padj');
if n==4
figure(1)
%first vertex Pmat(1,:) has coords [d,0,0,0]
d=-1;
%Specify rotation matrix to get coords of other points (want to kill
%last entry to make all coords [a,b,c,0]
R=0.5*[-3/d,-1/d,1/d,3/d; 1/d -3/d 3/d -1/d; 1, 3, 3, 1; 1,1,1,1];
%Center permutahedron at origin
Pmat_shift=Pmat-5/2;
%Calculate all other coords
Pmat_coord=zeros(Nsize,n);
for i=1:Nsize
Pmat_coord(i,:)=(R*(Pmat_shift(i,:)'))';
end
%Plot all points
hold on
for i=1:Nsize
scatter3(Pmat_coord(i,1),Pmat_coord(i,2),Pmat_coord(i,3),'o')
text(Pmat_coord(i,1),Pmat_coord(i,2),Pmat_coord(i,3),[' ',num2str(Pmat(i,:))])
end
%draw all edges
for i=1:Nsize
for j=(i+1):Nsize
if Padj(i,j)==1
plot3(Pmat_coord([i,j],1),Pmat_coord([i,j],2),Pmat_coord([i,j],3));
end
end
end
hold off
end
axis square;
Here's the result:

So something is very wrong. The edges connect the right pairs of vertices but something is still off. I think what's going on here is that I need to look at the inverse permutation of each vertex to get things right but, I'm not sure why this is necessary since I thought that by definition, the truncated octahedron is the projection from 4 dimensions into 3 dimensions of all coordinate permutations of (1,2,3,4), subsequently normalized. What's going here?
Please take a look at this tutorial posted at this link.
http://blogs.mathworks.com/graphics/2016/01/29/tiling-hexagons-and-other-permutohedra/
I think it does exactly what you want but incorporates graph theoretical concepts for a cleaner presentation.