如何在颜色栏中手动设置范围? [英] how to set the range in the colorbar manually?

查看:127
本文介绍了如何在颜色栏中手动设置范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的值范围很广,而以散点图(x,y,z)进行绘制时,显示z轴的色条显示了很宽的值范围,现在我对较低的范围值不感兴趣.是否有任何方法可以更改颜色栏中的范围. 我有以下代码要绘制的部分,我也打算绘制对数图.例如.我想将对数图中的范围设置为最大值的14.

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 range values. Is there any method to change the range in color bar. I have the following part of my code to plot, I also intend to plot the log plot. For eg. I want to set the range in my log plot to 14 to the maximum value.

我希望根本不显示某些值.因此色条的范围有限,例如从14到最大.目前,它在对数图中显示为9到最大值.

I want some values not to be displayed at all. so that the color bar has a limited range, say from 14 to maximum. At present it is showing from 9 to maximum in the log plot.

scatter(x(1:end-1), y(1:end-1), 5, gnd);

title('G plot (m^-^2)');

colorbar('eastoutside');

xlabel(' X-axis (microns)');

ylabel('Y-axis (microns)');

figure;

log_g=log10(gnd);

scatter(x(1:end-1), y(1:end-1), 5,log_g);

colorbar('eastoutside');

xlabel(' X-axis (microns)');

ylabel('Y-axis (microns)');

title('G Density, log plot (m^-^2)');

推荐答案

我相信caxis是您要查找的命令.用法:

I believe that caxis is the command you're looking for. Usage:

caxis([minValue maxValue]) 

使用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.

由于colorbar和朋友使用colormap,因此如果要调整使用的颜色数量,则必须调整当前的颜色图.这样做:

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);

当然,将其与caxis组合在一起是最强大的.

Of course, combining this with caxis is the most powerful.

如果您不想显示某些超出范围的值,那么这不是colorbarcaxis的工作,这取决于您-您必须调整绘制的数据,以便所有值您不想想要绘制的是NaN.这样做会使Matlab理解您不想绘制这些数据:

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

这篇关于如何在颜色栏中手动设置范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆