I've been trying to do this for a while now, but for some reason I can't do it.
I have a large data set, which includes a timeseries of parameter1 and parameter2. I am plotting parameter1 as a function of time, but would like the color of the plot to be based on the probability distribution of parameter2.
For example:
import numpy as np
import matplotlib.pyplot as plt
time = np.arange(0., 5., 0.02)
parameter1 = np.sin(2*np.pi*time)
###parameter2 = np.random.randn(10000)
parameter2 = np.cos(2*np.pi*time)
# Plot parameter1 as a function of time
plt.plot(time, parameter1)
# Plot parameter2 distribution
plt.hist(parameter2)
In my data parameter1 and parameter2 both vary as a function of time. Therefore, I want to color parameter1 using a colormap based on the distribution of paramter2. How would I do this? Is there a straightforward way of accomplishing this, that I'm not aware of? The main problem I have is that the parameters change differently with time, and so it's not clear to me how to do this.
EDIT: Both parameters share the same time data points. I.e. For each point in time, I have a value of parameter1 and parameter2. Therefore, although parameter1 is not related to parameter2 (even though, in the above example they are), they both share the same time axis.