I have a collection of particles, each represented by 4 features stored in 4 lists: energy, x_momentum, y_momentum, z_momentum.
Please find here an example with 4 particles:
x_momentum = [0.15216761841647822, 0.0018606956403060416, -0.2581646413098657, -0.06464056152956568]
y_momentum = [-0.006669552300356048, -0.21579226398008983, -0.16226640845867094, 0.029532453059122506]
z_momentum = [0.8616288523834605, 1.5346175299954392, 0.5915564583369708, 0.08989557604945903]
energy = [0.8764152818624683, 1.55052272693799, 0.6673967431272858, 0.12502712734367252]
I would like to plot each particle as an arrow in a 3-d space pointing in the space according its xyz momentum with the following specifications:
- each arrow should have a length according to its energy (higher energy longer arrow and vice-versa)
- each arrow should have a colour that depends on the direction according to a gradient. e.g. red for the arrows pointing mostly towards the same direction and blue for arrows pointing to more random directions.
- if point 1 and 2 not possible, at least the colour should reflect the energy i.e. all the arrows long the same but higher energy means reddish colours lower energy means blueish colour.
- lastly, I would like to resize the grid. right now it goes from -0.5 to 0.5 each axis but does not contain all the arrows. Moreover, if I am able to solve point 1. I want the axes to be coherent with the size of the arrows which depend on the energy. Therefore, if for example the highest energy is 3 and subsequently the arrow with that energy is long 3, than the range of the axes should be something like -4 to 4 to contain the arrow.
This is the code I have been able to write (python3).
fig = plt.figure(figsize=(20,16))
ax = fig.gca(projection='3d')
# Make the grid
x, y, z = 0,0,0
# Make the direction data for the arrows
u = x_momentum
v = y_momentum
w = z_momentum
ax.quiver(x, y, z,u,v,w, length=0.1, normalize=True)
plt.show()