def errorBand(x, yAvg, yStd, yDensity, plt, n_colors=None):
dmn = yDensity.min()<EOL>dmx = yDensity.max()<EOL>if n_colors is None:<EOL><INDENT>n_colors = dmx - dmn + <NUM_LIT:1><EOL><DEDENT>print(n_colors)<EOL>cm = plt.cm.get_cmap('<STR_LIT>', lut=n_colors)<EOL>relDensity = (yDensity - dmn) / (dmx - dmn)<EOL>bins = np.linspace(<NUM_LIT:0>, <NUM_LIT:1>, n_colors - <NUM_LIT:1>)<EOL>inds = np.digitize(relDensity, bins)<EOL>i0 = <NUM_LIT:0><EOL>try:<EOL><INDENT>while True:<EOL><INDENT>v0 = inds[i0]<EOL>am = np.argmax(inds[i0:] != v0)<EOL>if am == <NUM_LIT:0>:<EOL><INDENT>i1 = len(inds)<EOL><DEDENT>else:<EOL><INDENT>i1 = i0 + am<EOL><DEDENT>r = slice(i0, i1 + <NUM_LIT:1>)<EOL>col = cm(v0)<EOL>plt.fill_between(x[r], yAvg[r] - yStd[r], yAvg[r] + yStd[r],<EOL>alpha=<NUM_LIT:1>,<EOL>edgecolor=col,  <EOL>facecolor=col,  <EOL>linewidth=<NUM_LIT:1>)<EOL>i0 = i1<EOL><DEDENT><DEDENT>except IndexError:<EOL><INDENT>pass<EOL><DEDENT>plt.plot(x, yAvg, '<STR_LIT:k>', color='<STR_LIT>')<EOL>sm = plt.cm.ScalarMappable(cmap=cm, norm=plt.Normalize(vmin=dmn, vmax=dmx))<EOL>sm._A = []<EOL>plt.colorbar(sm)<EOL>plt.legend()<EOL>
plot error-band around avg
where colour equals to point density