python mpl: how to plot a point on a graph of 3D vectors, and the head of an arrow
<p>I have the following code to generate a triangle (from some lines) and a vector in a 3D figure:</p>

<pre><code>from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np

import sys

# D is the viewing direction.
# P is the "eye" point.
# A, B, and C are the points of the Triangle being tested against.

# make a shear matrix from the D vector.
def make_shear(d):
    print [1, 0, -d[0]/d[2] ];
    print [1, 0, -d[1]/d[2]];
    print [0, 0, 1/d[2]] ;
    return np.array([ [1, 0, -d[0]*1.0/d[2] ], [0, 1, -d[1]*1.0/d[2]], [0, 0, 1.0/d[2]] ]);

def draw_line(ax, A, B, c):
    ax.plot([A[0], B[0]], [A[1],B[1]],[A[2],B[2]], color=c)

plt.close('all');

fig1 = plt.figure();

ax = fig1.add_subplot(111, projection='3d')

P = np.array([3, 4, 2]);
P1 = np.array([1, 5, 7]);
D = P1 - P;
M = make_shear(D);

print "D = ", D
#print D[0];

print "M = ";
print M;

Dp = M.dot(D);

A =np.array([-5, 3, 5]);
B =np.array([1, 4, 10]);
C =np.array([-5, 5, 5]);

Ap = M.dot(A-P);
Bp = M.dot(B-P);
Cp = M.dot(C-P);

U = np.dot(Dp, np.cross(Cp, Bp));
V = np.dot(Dp, np.cross(Ap, Cp));
W = np.dot(Dp, np.cross(Bp, Ap));
print "U = ", U;
print "V = ", V;
print "W = ", W;

ax = fig1.add_subplot(111, projection='3d')
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')

draw_line(ax, A, B, 'g');
draw_line(ax, B, C, 'g');
draw_line(ax, C, A, 'g');
sf = 5; # scale factor, to make the direction more obvious...not sure this works.
ax.quiver(P[0], P[1], P[2], sf*D[0], sf*D[1], sf*D[2]); # head_width=0.05, head_length=0.1, fc='k', ec=ki");

b = 10;
ax.set_xlim([-b, b]);
ax.set_ylim([-b, b]);
ax.set_zlim([-b, b]);
plt.show();
</code></pre>

<ol>
<li>I want to add a single point the graph, say P, as a small red sphere.</li>
<li>I want add an arrow to the head of the vector drawn in the quiver statement.</li>
</ol>

<p>What is the most straightforward way to do these two things?</p>

<ol>
<li><p>Add the following line right after your <code>x.quiver...</code> line.</p>

<pre><code>ax.scatter(P[0], P[1], P[2], c='r')
</code></pre></li>
<li><p>Add the following lines right after your <code>x.quiver...</code> line.</p>

<pre><code>v = [0, 1, 0]
end_v = P + v
ax.quiver(end_v[0], end_v[1], end_v[2], v[0], v[1], v[2])
</code></pre></li>
</ol>

python numpy matplotlib vector point