# Generate the space in which the blobs will live xmin, xmax, ymin, ymax = (0, 100, 0, 100) n_bins = 100 xx = np.linspace(xmin, xmax, n_bins) yy = np.linspace(ymin, ymax, n_bins)
# Generate the blobs. The range of the values is roughly -.0002 to .0002 means_high = [20, 50] means_low = [50, 60] var = [150, 200]
# Create an alpha channel of linearly increasing values moving to the right. alphas = np.ones(weights.shape) alphas[:, 30:] = np.linspace(1, 0, 70)
# Normalize the colors b/w 0 and 1, we'll then pass an MxNx4 array to imshow colors = Normalize(vmin, vmax, clip=True)(weights) colors = cmap(colors)
# Now set the alpha channel to the one we created above colors[..., -1] = alphas
# Create the figure and image # Note that the absolute values may be slightly different fig, ax = plt.subplots() ax.imshow(greys) ax.imshow(colors, extent=(xmin, xmax, ymin, ymax)) ax.set_axis_off()
# Create an alpha channel based on weight values # Any value whose absolute value is > .0001 will have zero transparency alphas = Normalize(0, .3, clip=True)(np.abs(weights)) alphas = np.clip(alphas, .4, 1) # alpha value clipped at the bottom at .4
# Normalize the colors b/w 0 and 1, we'll then pass an MxNx4 array to imshow colors = Normalize(vmin, vmax)(weights) colors = cmap(colors)
# Now set the alpha channel to the one we created above colors[..., -1] = alphas
# Create the figure and image # Note that the absolute values may be slightly different fig, ax = plt.subplots() ax.imshow(greys) ax.imshow(colors, extent=(xmin, xmax, ymin, ymax))
# Add contour lines to further highlight different levels. ax.contour(weights[::-1], levels=[-.1, .1], colors='k', linestyles='-') ax.set_axis_off() plt.show()