I am trying to plot a line chart that shows the mean value for each point in time in a dataset (say you observe 100 datapoints for each day and plot the mean for each day) - this part is easy.
What I cannot figure out to do is how to add the distribution of observed values as a vertical histogram for each timestep. Because it may be a bit hard to describe, I made a pro-level paint drawing of the desired output:
#Data is in x, rows are observations, columns are timesteps
import numpy as np
import matplotlib.pyplot as plt
x = np.random.rand(100,10) + np.arange(0,10)/100
plt.plot(np.mean(x,axis=0))
plt.figure()
for i in range(x.shape[1]):
plt.hist(x[:,i], label="i")
So I can easily plot the mean and I can also easily plot the histograms, but I am struggling to combine them both into the same graph. I considering using violin plots, but didn't make any headway there either. Any help is much appreciated.