function json2StickManPlot(json2data, figID)

if ~isfield(json2data, 'People')
    title(sprintf('nTime=%u - no People data', json2data.nTime));
    return;
end

LineWidth = 3;

for p=1:length(json2data.People),
    if isfield(json2data.People{p}, 'joints'), % joints are there, plot the whole skeleton:
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.Head, json2data.People{p}.joints.Neck);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    hold on
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.Neck, json2data.People{p}.joints.SpineMid);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.Neck, json2data.People{p}.joints.ShoulderLeft);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.Neck, json2data.People{p}.joints.ShoulderRight);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.SpineMid, json2data.People{p}.joints.SpineBase);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.SpineBase, json2data.People{p}.joints.HipLeft);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.SpineBase, json2data.People{p}.joints.HipRight);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.HipRight, json2data.People{p}.joints.KneeRight);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.HipLeft, json2data.People{p}.joints.KneeLeft);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.KneeLeft, json2data.People{p}.joints.AnkleLeft);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.KneeRight, json2data.People{p}.joints.AnkleRight);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.AnkleRight, json2data.People{p}.joints.FootRight);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.AnkleLeft, json2data.People{p}.joints.FootLeft);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.ShoulderRight, json2data.People{p}.joints.ElbowRight);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.ShoulderLeft, json2data.People{p}.joints.ElbowLeft);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.ElbowLeft, json2data.People{p}.joints.WristLeft);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.ElbowRight, json2data.People{p}.joints.WristRight);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.WristLeft, json2data.People{p}.joints.HandLeft);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.WristRight, json2data.People{p}.joints.HandRight);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.HandRight, json2data.People{p}.joints.HandTipRight);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.HandLeft, json2data.People{p}.joints.HandTipLeft);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.HandRight, json2data.People{p}.joints.ThumbRight);
    plot3(X,Y,Z, 'LineWidth', LineWidth);
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.HandLeft, json2data.People{p}.joints.ThumbLeft);
    plot3(X,Y,Z, 'LineWidth', LineWidth);

        % Get head position again.
    [X,Y,Z] = jsonStruct2link(json2data.People{p}.joints.Head, json2data.People{p}.joints.Head);

    else % Only the head position was sent:
        X = double(json2data.People{p}.head.X);
        Y = double(json2data.People{p}.head.Y);
        Z = double(json2data.People{p}.head.Z);
    end
    validFace = str2num(json2data.People{p}.validFace);
    
        
    if validFace,
        % Writing person ID above their head:
        text(X(1), Y(1)+.125, Z(1), sprintf('%d', json2data.People{p}.iFace), 'color', 'black');
        plot3(X(1),Y(1),Z(1), 'o', 'MarkerSize', 20, 'MarkerFaceColor', [1,.75,.75], 'MarkerEdgeColor', 'none');        
        RotMatrix = quaternion(double([json2data.People{p}.faceRotation.w, json2data.People{p}.faceRotation.x, json2data.People{p}.faceRotation.y, json2data.People{p}.faceRotation.z]));
    else
        text(X(1), Y(1)+.125, Z(1), sprintf('%d', json2data.People{p}.iFace), 'color', 'red');
        plot3(X(1),Y(1),Z(1), 'o', 'MarkerSize', 20, 'MarkerFaceColor', [.75,.75,1], 'MarkerEdgeColor', 'none');        
        % Face not detected, use a vector that is orthogonal to the neck:
        % The lines below would be much nicer if I was using the quaternion
        % functions from the Aerospace Toolbox:
         if isfield(json2data.People{p}, 'joints'),  
             neck_w = json2data.People{p}.jointOrientations.Neck.w;
             neck_x = json2data.People{p}.jointOrientations.Neck.x;
             neck_y = json2data.People{p}.jointOrientations.Neck.y;
             neck_z = json2data.People{p}.jointOrientations.Neck.z;
         
         else % Only the head position was sent:
             hold on;
             neck_w = json2data.People{p}.neckOrientation.w;
             neck_x = json2data.People{p}.neckOrientation.x;
             neck_y = json2data.People{p}.neckOrientation.y;
             neck_z = json2data.People{p}.neckOrientation.z;
       
         end
        RotMatrix = quaternion(double([neck_w, neck_x, neck_y, neck_z]));
        RotMatrix = RotMatrix * [1 0 0; 0 -1 0; 0 0 -1]; % Rotate 180 degrees around the X axis
    end
    nose = RotMatrix*[0;0;-.125];
    earLeft = RotMatrix*[-.125;0;0];
    earRight = RotMatrix*[.125;0;0];
    
    X(2) = X(1)+earLeft(1);
    Y(2) = Y(1)+earLeft(2);
    Z(2) = Z(1)+earLeft(3);
    plot3(X,Y,Z, 'LineWidth', LineWidth, 'color', 'g');
    
    X(2) = X(1)+earRight(1);
    Y(2) = Y(1)+earRight(2);
    Z(2) = Z(1)+earRight(3);
    plot3(X,Y,Z, 'LineWidth', LineWidth, 'color', 'g');
    
    X(2) = X(1)+nose(1);
    Y(2) = Y(1)+nose(2);
    Z(2) = Z(1)+nose(3);
    plot3(X,Y,Z, 'LineWidth', LineWidth, 'color', 'r');    
    Q = matrix2quaternion(RotMatrix);
    A = quaternion2euler(Q,1);
    text(X(1), Y(1)+.5, Z(1), sprintf('yaw:%2.0f', A(2)), 'color', 'black');
    text(X(1), Y(1)+.375, Z(1), sprintf('pitch:%2.0f', A(1)), 'color', 'black');
    
    % "cleaning up" angles
    big_angles = abs(A)>90;
    A(big_angles) = sign(A(big_angles)).*(180-abs(A(big_angles)));
    
    text(X(1), Y(1)+.25, Z(1), sprintf('roll:%2.0f', A(3)), 'color', 'black');
end
axis([-2 2, -1.2 1.5, 0 5])
xlabel('X');
ylabel('Y');
zlabel('Z');
view([180,-90]);
if nargin > 1,
    cameratoolbar(figID,'Show');
    % cameratoolbar(figID,'SetMode', 'orbit');
    cameratoolbar(figID,'SetCoordSys','y');
end
grid on
title(sprintf('nTime=%u', json2data.nTime));
hold off;
end