Skip to content
Advertisement

Connect 3D points in matplotlib scatter

I have the following code, that generates a 3D scatter plot:

JavaScript

What I’m trying to do is connect those 2 points using a directional arrow.

What I’ve got

What I want: What i want

Tried ax.annotation but it doesn’t work. Any suggestions? Preferencially, a for loop to annotate N points, considering the (x1, y1, z1) and (x2, y2, z2) coordinates.

Advertisement

Answer

This is a possible solution, p1 and p2 are just some points for testing purpose:

JavaScript

Output:

enter image description here

basically ax.quiver3D has following parameter in the parenthesis:

JavaScript

x, y, z is the initial position and dx, dy, dz is the vector direction.

As for the loop, I think you will manage to adapt the code yourself, will you?

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement