Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: colormap for scatter plot

Subject: colormap for scatter plot

From: Faisal

Date: 10 Nov, 2007 10:26:52

Message: 1 of 3

Hi
I can use colormap based on Z values as
scatter3(X,Z,Y,5,Z,'filled');
However, I want to fix the range of Z between 0 and 8 and
the color for that range remains fix. Such that if the Z
data has only values between 0 and 5 then the colormap
should not re-adjust between blue and red for this range but
use maximum value for 5 as if 8 is also there in the data( I
mean red not to be assigned to 5 (max value))
I have used
scatter3(X,Z,Y,5,linspace(0,8,length(X))', 'filled');
but it linearly colormaps in Y dimension.
Thanks,

Subject: colormap for scatter plot

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 11 Nov, 2007 01:39:54

Message: 2 of 3

In article <fh411b$69i$1@fred.mathworks.com>,
Faisal <faisal_mufti.nospam@yahoo.com> wrote:

>I can use colormap based on Z values as
>scatter3(X,Z,Y,5,Z,'filled');
>However, I want to fix the range of Z between 0 and 8 and
>the color for that range remains fix. Such that if the Z
>data has only values between 0 and 5 then the colormap
>should not re-adjust between blue and red for this range but
>use maximum value for 5 as if 8 is also there in the data( I
>mean red not to be assigned to 5 (max value))
>I have used
>scatter3(X,Z,Y,5,linspace(0,8,length(X))', 'filled');
>but it linearly colormaps in Y dimension.

You will have to provide scatter3 with direct color values
instead of with coordinates to be interpolated.

The below is arranged to only use colors from the current colormap,
and takes into account the boundary conditions on the array sizes
and indices.

minz = 0; maxz = 8;
curcolmap = colormap;
curmapsize = size(curcolmap,1);
mapz = round(1 + (Z - minz) ./ (maxz-minz) .* (curmapsize-1));
scatter3(X, Z, Y, 5, curcolmap(mapz,:), 'filled')
--
   "I was very young in those days, but I was also rather dim."
   -- Christopher Priest

Subject: colormap for scatter plot

From: Faisal

Date: 11 Nov, 2007 10:25:02

Message: 3 of 3

Thanks Walter, I have used 'caxis([0 8]);' and it solves my
purpose.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

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.
Related Topics