I have a matrix containing integers ranging from 0 to 20. The regions with the same integer are formed in a quite random fashion. I want to color code each integer with a different degree of grayscale. So for example, for regions with 0, I want them to be white, then for regions with 1, 5% transparency of black, for regions with 2, 10% transparency of black,..., for regions with 20, totally black.
I've tried to get the coordinates of each region, but that does not seem to be efficient for my matrix.
How can I change the transparency of my regions based on their value?
You can use
surface()with itsFaceAlphaname-value pair. It only accepts scalars though, so you'll have to plot each of your patches separately, something along the lines of:Results in, on my R2007b,
If you're good with just a gray-scale image, rather than true transparency, you can simply use
imagesc(my_matrix); colormap(gray).