I am trying to plot multiple lines in space (each of which connect a pair of points) on one 3D graph in Python using matplotlib, and I want each line to be colored differently based on how long it is (i.e., the longest line would be red, a middle-length line would be orange-ish, etc.).
I have all of the line lengths computed.
My points' coordinates are carried in separate arrays like so:
x1 = # all of the x coordinates of the primary points
y1 = # all of the y coordinates of the primary points
z1 = # all of the z coordinates of the primary points
x2 = # all of the x coordinates of the secondary points
y2 = # all of the y coordinates of the secondary points
z2 = # all of the z coordinates of the secondary points
where each line has endpoints (x1[i],y1[i],z1[i])
and (x2[i],y2[i],z2[i])
and i
is the index of the line.
How might I use a heatmap or some other Python function to color each line accordingly? I think I understand how heatmaps can be used to plot a set of data, but I am trying to plot separate lines and color them based on some reference length (i.e., lenth_max
, which would be the "hottest" length).