Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
imagesc

Subject: imagesc

From: Wendy

Date: 4 Apr, 2010 14:37:04

Message: 1 of 5

Hi all,

I read in a matrix from xls file. The matrix is as follows

pvalue = [ NaN NaN NaN NaN;
NaN NaN 1.00000000000000e-05 NaN;
NaN 4.00000000000000e-05 0 NaN;
NaN 0 0 NaN;
NaN NaN NaN NaN];

Those NaN elements are empty in the excel file. As all the pvalues are >=0, I set NaN elements to -2, and set caxis=([0 4e-5]). As -2 is out of my caxis, all the -2 elements are plotted with the minimum caxis. I want the -2 elements to be empty on the plot, like surf function does. Can anyone give me some hint on this issue? I was suggested to set a color code for -2 element, but I could not find how to set a color code to a value.

Thank you very much.
Wendy

Subject: imagesc

From: Anthony Hopf

Date: 4 Apr, 2010 15:50:10

Message: 2 of 5

Why not keep the NaN values and plot that? The NaN values will have their own color assigned to them.

"Wendy " <wlq121@gmail.com> wrote in message <hpa86g$ngb$1@fred.mathworks.com>...
> Hi all,
>
> I read in a matrix from xls file. The matrix is as follows
>
> pvalue = [ NaN NaN NaN NaN;
> NaN NaN 1.00000000000000e-05 NaN;
> NaN 4.00000000000000e-05 0 NaN;
> NaN 0 0 NaN;
> NaN NaN NaN NaN];
>
> Those NaN elements are empty in the excel file. As all the pvalues are >=0, I set NaN elements to -2, and set caxis=([0 4e-5]). As -2 is out of my caxis, all the -2 elements are plotted with the minimum caxis. I want the -2 elements to be empty on the plot, like surf function does. Can anyone give me some hint on this issue? I was suggested to set a color code for -2 element, but I could not find how to set a color code to a value.
>
> Thank you very much.
> Wendy

Subject: imagesc

From: Wendy

Date: 4 Apr, 2010 16:06:02

Message: 3 of 5

Hi Anthony,

Thank you for your reply. The NaN are assigned blue. This makes the NaN elements and my small pvalues indistinguishable.

Wendy

"Anthony Hopf" <anthony.hopf@gmail.com> wrote in message <hpacfh$jcj$1@fred.mathworks.com>...
> Why not keep the NaN values and plot that? The NaN values will have their own color assigned to them.
>
> "Wendy " <wlq121@gmail.com> wrote in message <hpa86g$ngb$1@fred.mathworks.com>...
> > Hi all,
> >
> > I read in a matrix from xls file. The matrix is as follows
> >
> > pvalue = [ NaN NaN NaN NaN;
> > NaN NaN 1.00000000000000e-05 NaN;
> > NaN 4.00000000000000e-05 0 NaN;
> > NaN 0 0 NaN;
> > NaN NaN NaN NaN];
> >
> > Those NaN elements are empty in the excel file. As all the pvalues are >=0, I set NaN elements to -2, and set caxis=([0 4e-5]). As -2 is out of my caxis, all the -2 elements are plotted with the minimum caxis. I want the -2 elements to be empty on the plot, like surf function does. Can anyone give me some hint on this issue? I was suggested to set a color code for -2 element, but I could not find how to set a color code to a value.
> >
> > Thank you very much.
> > Wendy

Subject: imagesc

From: Anthony Hopf

Date: 4 Apr, 2010 16:36:05

Message: 4 of 5

How about making the NaN values very large... like 100 and limiting your color scale to 1e-5 to 1. This will set your small values to different colors and your 100 (read NaN) to the color for 1. you could also use 1e-5 to 1e-3.

T

"Wendy " <wlq121@gmail.com> wrote in message <hpadda$1vi$1@fred.mathworks.com>...
> Hi Anthony,
>
> Thank you for your reply. The NaN are assigned blue. This makes the NaN elements and my small pvalues indistinguishable.
>
> Wendy
>
> "Anthony Hopf" <anthony.hopf@gmail.com> wrote in message <hpacfh$jcj$1@fred.mathworks.com>...
> > Why not keep the NaN values and plot that? The NaN values will have their own color assigned to them.
> >
> > "Wendy " <wlq121@gmail.com> wrote in message <hpa86g$ngb$1@fred.mathworks.com>...
> > > Hi all,
> > >
> > > I read in a matrix from xls file. The matrix is as follows
> > >
> > > pvalue = [ NaN NaN NaN NaN;
> > > NaN NaN 1.00000000000000e-05 NaN;
> > > NaN 4.00000000000000e-05 0 NaN;
> > > NaN 0 0 NaN;
> > > NaN NaN NaN NaN];
> > >
> > > Those NaN elements are empty in the excel file. As all the pvalues are >=0, I set NaN elements to -2, and set caxis=([0 4e-5]). As -2 is out of my caxis, all the -2 elements are plotted with the minimum caxis. I want the -2 elements to be empty on the plot, like surf function does. Can anyone give me some hint on this issue? I was suggested to set a color code for -2 element, but I could not find how to set a color code to a value.
> > >
> > > Thank you very much.
> > > Wendy

Subject: imagesc

From: us

Date: 4 Apr, 2010 17:32:23

Message: 5 of 5

"Wendy " <wlq121@gmail.com> wrote in message <hpa86g$ngb$1@fred.mathworks.com>...
> Hi all,
>
> I read in a matrix from xls file. The matrix is as follows
>
> pvalue = [ NaN NaN NaN NaN;
> NaN NaN 1.00000000000000e-05 NaN;
> NaN 4.00000000000000e-05 0 NaN;
> NaN 0 0 NaN;
> NaN NaN NaN NaN];
>
> Those NaN elements are empty in the excel file. As all the pvalues are >=0, I set NaN elements to -2, and set caxis=([0 4e-5]). As -2 is out of my caxis, all the -2 elements are plotted with the minimum caxis. I want the -2 elements to be empty on the plot, like surf function does. Can anyone give me some hint on this issue? I was suggested to set a color code for -2 element, but I could not find how to set a color code to a value.
>
> Thank you very much.
> Wendy

one of the solutions

     m=[
          NaN NaN NaN NaN
          NaN NaN 1e-005 NaN
          NaN 4e-005 0 NaN
          NaN 0 0 NaN
          NaN NaN NaN NaN
     ];
     m=flipud(m); % <- !!!!!
     imagesc(m);
     ma=~isnan(m);
     alpha(double(ma));
     colorbar;
     colormap(jet);
     axis image;
     axis xy; % <- !!!!!

us

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us