f



creating a custom colormap

Hi,
I would like to make the following colormap;
Suppose the data consists of points in the interval 
minx < 0 and maxx > 0.
I would like to have 2 colors: fading from darkred (for minx) to
white for 0 and then increasing in intensity to darkblue (for maxx).
(i.e. i want to visualize electric charges for 0 for neutral (white)
positive charge by blue and negative charge by red).
i would really appreciate any help.
thanks
0
les_ander (115)
10/12/2004 3:57:45 PM
comp.soft-sys.matlab 211266 articles. 22 followers. lunamoonmoon (257) is leader. Post Follow

6 Replies
571 Views

Similar Articles

[PageSpeed] 49

Les,

Try this:

cmap=[sqrt(gray(64));sqrt(flipud(gray(64)))];
cmap(1:64,1)=1;
cmap(65:end,3)=1;
imagesc(peaks(30));caxis([-6 6]);colormap(cmap);colorbar

les ander wrote:
>
>
> Hi,
> I would like to make the following colormap;
> Suppose the data consists of points in the interval
> minx < 0 and maxx > 0.
> I would like to have 2 colors: fading from darkred (for minx) to
> white for 0 and then increasing in intensity to darkblue (for
> maxx).
> (i.e. i want to visualize electric charges for 0 for neutral
> (white)
> positive charge by blue and negative charge by red).
> i would really appreciate any help.
> thanks
>
0
mike23 (378)
10/14/2004 1:42:10 AM
Hi Mike,
thanks--this does what I want.
could you explain the first line? 
thanks

"Mike Nospam" <mike@nospam.com> wrote in message news:<eeecc23.0@webx.raydaftYaTP>...
> Les,
> 
> Try this:
> 
> cmap=[sqrt(gray(64));sqrt(flipud(gray(64)))];
> cmap(1:64,1)=1;
> cmap(65:end,3)=1;
> imagesc(peaks(30));caxis([-6 6]);colormap(cmap);colorbar
> 
> les ander wrote:
> >
> >
> > Hi,
> > I would like to make the following colormap;
> > Suppose the data consists of points in the interval
> > minx < 0 and maxx > 0.
> > I would like to have 2 colors: fading from darkred (for minx) to
> > white for 0 and then increasing in intensity to darkblue (for
> > maxx).
> > (i.e. i want to visualize electric charges for 0 for neutral
> > (white)
> > positive charge by blue and negative charge by red).
> > i would really appreciate any help.
> > thanks
> >
0
les_ander (115)
10/14/2004 9:33:51 PM
les ander wrote:
>
>
<snip, Mike who hates obfuscated code is asked to explain how his
code works...

Ha ha ;-)
0
10/14/2004 9:42:26 PM
les_ander@yahoo.com (les ander) writes:

> Hi Mike,
> thanks--this does what I want.
> could you explain the first line? 
> thanks
>
> "Mike Nospam" <mike@nospam.com> wrote in message news:<eeecc23.0@webx.raydaftYaTP>...
>> Les,
>> 
>> Try this:
>> 
>> cmap=[sqrt(gray(64));sqrt(flipud(gray(64)))];
>> cmap(1:64,1)=1;
>> cmap(65:end,3)=1;
>> imagesc(peaks(30));caxis([-6 6]);colormap(cmap);colorbar

First type gray(64) and watch the output.
Then type sqrt(gray(64))
Then flipud(gray(64))
Then...

There's probably no better way to understand code than to step through
it and watch what happens.

As a bonus, try

gray(32)
help gray
help flipud


-- 
Peter Boettcher <boettcher@ll.mit.edu>
MIT Lincoln Laboratory
MATLAB FAQ: http://www.mit.edu/~pwb/cssm/
0
boettcher (2304)
10/14/2004 10:06:26 PM
Steve,

I have to say you got me on that one!! I laughed out loud when I read
your post. Keep those zingers coming!

Thanks for making my day, Mike

P.S. Les, I hope Peter's suggestion helped you sort out the
obfuscation. Just my muddy attempt to make the colormap you
requested.

Steve Amphlett wrote:
>
>
> les ander wrote:
>>
>>
> <snip, Mike who hates obfuscated code is asked to explain how
> his
> code works...
>
> Ha ha ;-)
0
mike23 (378)
10/15/2004 11:00:14 AM
Mike Nospam wrote:
>
<snip, cruel piss-take...

> I have to say you got me on that one!! I laughed out loud when I
> read
> your post. Keep those zingers coming!
>
> Thanks for making my day, Mike

Sorry Mike, but it was a bit of an open goal :-)

If you fancy a rematch, see if you you can better my recent
(beer-fuelled) palindrome homework solution.

- Steve
0
10/15/2004 9:58:28 PM
Reply: