Creating a customized grid on a imagesc() figure

6 views (last 30 days)
Hi,
I have a matrix of values between -1 and 1, I look it up with imagesc().
I would like to trace a customized grid over that image to delimit portions of the "matrix" (datapoints that share a common property).
I thougt it would work to make up a second matrix with lines and rows full of NaNs or Inf or some special value.
But imagesc() will trace NaN and Inf in the color of the min and max in the matrix, not some special color.
So, is there a way to trace a grid on top of imagesc(), or to set the colormap in such a way that Inf (for example) are renderred black and the other values are renderred as in the normal colormap "jet"?
Thank you very much laurie

Accepted Answer

Walter Roberson
Walter Roberson on 20 Apr 2012
Create a second image located at exactly the same position as the first, with the lines that you want, and with AlphaData set to 0 where the underlying image should show through, and 1 where the overlay should show through. The second image would have to be truecolor (RGB) to use different colors than are in the original image. Note that if you do this then you will need to use the OpenGL renderer as it is the only one that supports transparency.
Alternately after drawing your base image, use line() specifying RGB colors to draw on the grid.
It is not possible to "exempt" particular values from the colormap: if you are using pseudocolor then every color in the image must appear somewhere in the colormap.
  2 Comments
laurie
laurie on 20 Apr 2012
thank you. the first solution seems too complicated for me so i'll try with line() and come back :-)

Sign in to comment.

More Answers (0)

Categories

Find more on Colormaps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!