but it does not work... i see that the same color is used
for two different values and the colorbar has all the
elements grouped down and not nicely distributed along the
bar.
any suggestions on how to improve this "poor" script?
"carmelo " <km.nospam.scriba.nospam@yahoo.esnospam> wrote
in message <fqp846$a3c$1@fred.mathworks.com>...
> "us " <us@neurol.unizh.ch> wrote in message <fqp3t6
> $aae$1@fred.mathworks.com>...
> > "carmelo ":
> > <SNIP colorbar-tick headache...
> >
> > one of the solutions
> >
> > % the data
> > a=magic(5);
> > b=fix(a/2)-1;
> > c=[a,b];
> > % the engine
> > cu=unique(c);
> > n=numel(cu);
> > imagesc(c);
> > colormap(jet(n));
> > ch=colorbar;
> > yl=get(ch,'ylim');
> > ys=diff(yl)/n;
> > yt=linspace(yl(1)+ys,yl(2),n)-.5*ys;
> > % - the colorbar
> > set(ch,'ytick',yt,'yticklabel',cu);
> >
> > us
>
> Thanks us!!
>
oops! it seems that it does not work like i wanted it to
work. i have 6 unique elements in c but when i do:
imagesc(c);
colormap(jet(n));
the same color is assigned to two different values in c
and the colorbar is not correct (e.g. value 27 gets yellow
but in the colorbar yellow corresponds to value 35).
am i doing something wrong?
"us " <us@neurol.unizh.ch> wrote in message
<fqr3qr$82u$1@fred.mathworks.com>...
> "carmelo ":
> <SNIP useless amount of data...
>
> do not copy/paste a huge matrix, which - to boot -
cannot
> be recovered due formatting issues; this is tedious...
>
> create the smallest possible data set that reproduces
your
> problem...
>
> now, looking at some of the data it seems you have
> something like
>
> c=[0,25:27,33,37,38];
>
> the engine proposed earlier assumes that your <cu> is
> continuous!
> otherwise, simply adjust the engine as follows
>
> c=[
> 0,25,26,33
> 27,0,35,38
> ];
> % the engine
> cu=unique(c);
> [cx,cx]=histc(c,cu); % <- add this!
> n=numel(cu);
> imagesc(cx); % <- use this!
> colormap(jet(n));
> ch=colorbar;
> yl=get(ch,'ylim');
> ys=diff(yl)/n;
> yt=linspace(yl(1)+ys,yl(2),n)-.5*ys;
> % - the colorbar
> set(ch,'ytick',yt,'yticklabel',cu);
>
> us
sorry about posting the original c matrix, i thought that
it could help... I regretted my decision when i saw the re-
formating after posting the message....and, indeed, the
message was that the values are not continous
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.