From: Frank Chang on
Hi Group,

I have been trying to figure out how to fix limits of the colorbars
but haven't come to a solution yet. I am wondering if you could please
give me some tip.

Basically, I have some data that I'd like to view in 2D images. I have
been using commands like this to draw graphs:

imagesc(rand(4,4));
colormap('default'); colorbar

This gives the colorbar automatically. But I'd like to have some
control over the colorbar. For example, I know the range of a random
number is between (0, 1). Therefore if I set the range of the colorbar
to be [0, 2], every data point will be assigned a color. But I am lack
of understanding to the matlab graphics to make it happen. Please
direct me to somewhere if you can. Thank you!

Best,
Frank
From: Lars on
Frank Chang <etaghtron(a)gmail.com> wrote in message <9ca1ba1e-9313-4afb-a00c-899d1a82c5a6(a)e30g2000vbl.googlegroups.com>...
> ...
> control over the colorbar. For example, I know the range of a random
> number is between (0, 1). Therefore if I set the range of the colorbar
> to be [0, 2], every data point will be assigned a color. But I am lack
> of understanding to the matlab graphics to make it happen. Please

This is a long-standing hurdle that I at least have not found a simple answer to:
see this link (beware of line breaks)
<http://blogs.mathworks.com/pick/2010/05/28/creating-and-exporting-publication-quality-graphics/#comments>

....and just to give a BUMP to what I wrote (in my blog comment #6):

"[someone at TMW] (or one one of the other bloggers) give a rundown on how to take full control of the details of these three commands [i.e. colorbar, legend, and boxplot]"

TMW anyone ?

Lars
From: Frank Chang on
On Jun 11, 12:16 pm, "Lars " <lars.barr...(a)myworkplace.se> wrote:
> Frank Chang <etaght...(a)gmail.com> wrote in message <9ca1ba1e-9313-4afb-a00c-899d1a82c...(a)e30g2000vbl.googlegroups.com>...
> > ...
> > control over the colorbar. For example, I know the range of a random
> > number is between (0, 1). Therefore if I set the range of the colorbar
> > to be [0, 2], every data point will be assigned a color. But I am lack
> > of understanding to the matlab graphics to make it happen. Please
>
> This is a long-standing hurdle that I at least have not found a simple answer to:
> see this link (beware of line breaks)
> <http://blogs.mathworks.com/pick/2010/05/28/creating-and-exporting-pub...>
>
> ...and just to give a BUMP to what I wrote (in my blog comment #6):
>
> "[someone at TMW] (or one one of the other bloggers) give a rundown on how to take full control of the details of these three commands [i.e. colorbar, legend, and boxplot]"
>
> TMW anyone ?
>
> Lars

Lars,

Thank you for your response. I just need some simple control over
colorbar but it keeps escaping me. :)

I guess I am just going to cheat here. I have about 100,000 pixels. I
will just manually set the the pixel with smallest value to be 0 and
the largest to be 2. This way I force a colorbar to this graph. Not
the best way; but at least it gives me some control.

I do, however, would like to know how this can be done without
cheating...

Frank
From: Lars on
Frank Chang <etaghtron(a)gmail.com> wrote in message <7c16f4ce-f847-4d3b-935c-9560969302a0(a)f6g2000vbl.googlegroups.com>...
> I guess I am just going to cheat here. I have about 100,000 pixels. I
> will just manually set the the pixel with smallest value to be 0 and
> the largest to be 2. This way I force a colorbar to this graph. Not
> the best way; but at least it gives me some control.

Well, here are som thoughts/recollections from when I last tweaked a colorbar:

- the colorbar object is just an axes object under the figure.
- the handle graphics "Tag" is something like 'TMW_colorbar' or the like.
- if you remove this "Tag" string some of the automatic/dynamic formatting will disappear. Then you are in a better position to set your own YLim, YTick, YTickLabels, CLim,YLabel, ....
- I think there might be a ResizeFcn that you might want to remove.
- Under the Colorbar axes object there is an image object (or was it surface?) that is the actual colours of the scale
- Also this image(/surface?) object has a Tag like "TMW_...." string that you probably want to remove to further mute the automatic formatting.
- If you want the colorbar ticks (scale labels) to line up with the borders/centres of
of the individual colours of the scale (mainly unseful if do not have to many colours) then you just have to count the number of colours and have one more ticks.

hth
Lars
From: matt penrice on
On Jun 11, 8:29 am, Frank Chang <etaght...(a)gmail.com> wrote:
> Hi Group,
>
> I have been trying to figure out how to fix limits of the colorbars
> but haven't come to a solution yet. I am wondering if you could please
> give me some tip.
>
> Basically, I have some data that I'd like to view in 2D images. I have
> been using commands like this to draw graphs:
>
> imagesc(rand(4,4));
> colormap('default'); colorbar
>
> This gives the colorbar automatically. But I'd like to have some
> control over the colorbar. For example, I know the range of a random
> number is between (0, 1). Therefore if I set the range of the colorbar
> to be [0, 2], every data point will be assigned a color. But I am lack
> of understanding to the matlab graphics to make it happen. Please
> direct me to somewhere if you can. Thank you!
>
> Best,
> Frank


Try

caxis([lower,upper])

this will set everything above your upper limit to it and samething
for your lower limit. Not sure if this is what you were looking for.

good luck

matt