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];
All the NaN are empty elements in the excel file. I want to plot the pvalue using imagesc and indicate the empty elements as the background colour. However, Matlab treats the NaN as the minimum value (0) and indicates those 'NaN' positions blue on the plot. Is there a way that I can plot the 'NaN' elements as the background colour and only plot those elements that I have value with?
Hope I made the question clear. Thank you very much,
Wendy
Anyway, once you've set the nan's to the new value, then you need to
set up a colormap where the color at the index of the new value is the
color that you desire the nan pixels to have.
Thank you,
Wendy
ImageAnalyst <imagea...@mailinator.com> wrote in message <9d837299-3209-4da3...@y17g2000yqd.googlegroups.com>...
Thank you very much.
Wendy
ImageAnalyst <imagea...@mailinator.com> wrote in message <9d837299-3209-4da3...@y17g2000yqd.googlegroups.com>...
Hi Wendy,
I am having the same problem as you, I have a matrix with NaN values and I am displaying them on an imagesc.
Did you get a solution for the problem? how do you display (for example) NaN values in grey?
Thanks in advance for your information.
% Data:
data = peaks(256);
data(rand(size(data))<0.01) = NaN;
% Command:
sc(data, 'jet', [0.5 0.5 0.5]);
You can download sc here:
http://www.mathworks.com/matlabcentral/fileexchange/16233-sc-powerful-image-rendering
HTH,
Oliver
Hi Oliver!!!
Thank you very much for your reply!
I have tested sc with your example, and it worked ok, and now I am trying it on my matrix (which is (3732*12) and it appears like a (1*12) on the figure...
What could be the problem?
Thank you so much for your help :-)
Camille.
I have no idea what the problem is. This works fine for me:
>> A = rand(3732, 12);
>> A(rand(size(A))<0.01) = NaN;
>> sc(A, 'jet', 'k')
Hi again,
I found myself the answer to my question reading all the posts in the sc page:
"Justin - if you prefer the image displaying properties of imagesc I suggest you use image(sc(X)). However, you then don't get the correct colorbar. If it's just the aspect ratio you don't like then call set(gca, 'DataAspectRatioMode', 'auto') after sc."
I add set(gca, 'DataAspectRatioMode', 'auto') after my sc command and that worked.
THANK YOU A LOT OLIVER!!
Hi oliver,
Thanks again, I have found the solution to this problem.
1 more question: I have seted the naN value to black. this color appear in the colorbar, just on the bottom of the colorbar. is there a way not to see this black color, so that my colorbar begins at the real minimum value (not NaN)
Again, thank you a lot for your very usefull tool, I have been searching that type of thing a long time and had many problems with other tools...
Thank you!
Camille,
When I try:
data = peaks(256);
data(rand(size(data))<0.01) = NaN;
sc(data, 'jet', [0 0 0]);
colorbar
I do not see the color black at the bottom of the colorbar. If you change the NaN color to red you will not see red either.
I updated sc yesterday. Make sure you are using the latest version so we are using the same code.
Regards,
Oliver
Hi Oliver,
In fact I had downloaded apparently a old version of sc, I just went to your page and downloaded the newest version, which is a complete folder (the one I downloaded yesterday was a single sc.m file).
I will try with this and tell you the results when I get them.
Thanks again!
Hi Oliver,
Well, I have tried it with all the suggestions you gave me and that work great! xis on, labels, no black color on the colorbar...
Nevertheless, I have a little problem. I have a buttondownfcn defined in my GUI, which displays a vertical line where you click and plot the corresponding profile (values of z) on another axe. When I have my subplot made by imagesc that work perfectly (but I don't have all the advantages of the sc, of course), but when I use sc, and I click on my subplot, then nothing happens (like if the buttondownfc where disabled by sc), and on the toolbar I cn see that the colorbar button is pushed, active.
can you help me fixing that...
thank you so much for all your help, your function is really really fantastic though!!!
Hi Camille
I'm surprised to hear about the button callback not working. If you email me directly the minimal amount of code required to replicate the problem, then I'll take a look.
Thanks,
Oliver