I have been trying to visualize a path saved in an array and to apply a color gradient along the line.
This is what I have so far:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
arr = np.array([[24.99487317, 55.466666 , 0. ],
[24.99487367, 55.46666917, 1. ],
[24.99487217, 55.46667017, 2. ],
[24.99487183, 55.4666715 , 3. ],
[24.99487133, 55.466673 , 4. ],
[24.99487267, 55.466674 , 5. ]])
fig, ax = plt.subplots()
ax.plot(arr[:, 0], arr[:, 1], c=cm.hot(arr[:, 2]), linestyle='dashed')
plt.show()
I want that more recent points are evaluated higher (or more brighter on the 'hot' colormap). Somehow I always get the error:
ValueError: Invalid RGBA argument: array([[0.0416, 0. , 0. , 1. ],
[1. , 1. , 1. , 1. ],
[1. , 1. , 1. , 1. ],
...,
[1. , 1. , 1. , 1. ],
[1. , 1. , 1. , 1. ],
[1. , 1. , 1. , 1. ]])
I can't find any proper example in the docs and I do not know which shape the return values of cm.hot have to have (I tried various ways, alternatively with plt.scatter and the cmap/norm argument but same error)
How do I need to apply the cmap to get a line that gets continously brighter for later observations?