Creating a customized grid on a imagesc() figure

조회 수: 2 (최근 30일)
laurie
laurie 2012년 4월 19일
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

채택된 답변

Walter Roberson
Walter Roberson 2012년 4월 20일
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
laurie
laurie 2012년 4월 20일
thank you. the first solution seems too complicated for me so i'll try with line() and come back :-)
laurie
laurie 2012년 4월 20일
thanks, it worked :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Color and Styling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by