I have a wide range of values and while plotting as a scatter(x,y,z), the colorbar showing the z axis shows a wide range of values, now I am not interested in the lower rang
Try this:
cmap = colormap; % get current colormap
cmap=cmap([min max],:); % set your range here
colormap(cmap); % apply new colormap
colorbar();
I believe that caxis
is the command you're looking for. Usage:
caxis([minValue maxValue])
Using caxis
like this, all values outside the range [minValue maxValue]
will be coloured with the lowest or highest value in the colormap, respectively.
Since colorbar
and friends use colormap
, you'll have to adjust the current colormap if you want to adjust the number of colors used. Do this like so:
%# get current colormap
map = colormap;
%# adjust for number of colors you want
rows = uint16(linspace(1, size(map,1), NUM_COLORS)) ;
map = map(rows, :);
%# and apply the new colormap
colormap(map);
Of course, combining this with caxis
is the most powerful.
If you don't want to show some values outside of range, that's not a job for colorbar
or caxis
, that's up to you -- you'll have to adjust the data that's plotted so that all values you don't want plotted are NaN
. Doing so will make Matlab understand that you don't want to plot these data:
data( indices_to_data_not_to_plot ) = NaN;
surf(x,y,data); %# or whatever you're using
How about this?
% don’t know why, but apparently your x and y are one value too long?
x = x(1:end-1); y = y(1:end-1);
% only plot values of 14 or higher
scatter(x(gnd>=14), y(gnd>=14), 5, gnd(gnd>=14);