Plotting multiple Gaussian processes with plot_gp_dist

@bwengals thanks a lot for your solution which helps a lot!

I implemented your code, then it looks like this:

For still having the color gradients, I now adapted your solution a bit:

cmap = plt.get_cmap(palette)
percs_color = np.linspace(51, 99, 20)
percs_alpha = np.linspace(51, 99, 20)
colors = (percs_color - np.min(percs_color)) / (np.max(percs_color) - np.min(percs_color))
samples = samples.T
x = x.flatten()
alphas = (percs_alpha - np.min(percs_alpha)) / (np.max(percs_alpha) - np.min(percs_alpha))
for i, p in enumerate(percs_color[::-1]):
    upper = np.percentile(samples, p, axis=1)
    lower = np.percentile(samples, 100 - p, axis=1)
    color_val = colors[i]
    ax.fill_between(x, upper, lower, color=cmap(color_val), alpha=alphas[i], **fill_kwargs)

Then we do have a color as well as an alpha gradient which let it looks like this:

So now it’s way better than in the beginning. Still, I’m not 100 percent happy. I guess I need to play around with the values of percs_alpha and percs_color to get a better result.

1 Like