Matlab中散点图的常用色条
我想让每个子图共享相同的颜色条比例。我知道Matlab中散点图的常用色条,matlab,plot,scatter-plot,colorbar,Matlab,Plot,Scatter Plot,Colorbar,我想让每个子图共享相同的颜色条比例。我知道caxis适用于大于1的整数,但使用caxis值如0.001似乎有问题 x = 0:1:10; y = 0:1:10; z1 = .1:-.01:0; z2 = .01:-.001:0; figure; subplot(1,2,1); scatter(x,y,10,z1); colorbar; subplot(1,2,2); scatter(x,y,10,z2); colorbar; 现在我想让散点子图有一个通用的色条比例。我尝
caxis
适用于大于1的整数,但使用caxis
值如0.001似乎有问题
x = 0:1:10;
y = 0:1:10;
z1 = .1:-.01:0;
z2 = .01:-.001:0;
figure;
subplot(1,2,1);
scatter(x,y,10,z1); colorbar;
subplot(1,2,2);
scatter(x,y,10,z2); colorbar;
现在我想让散点子图有一个通用的色条比例。我尝试使用caxis
,但是没有得到预期的结果左轴不能正确缩放,因为它们都是棕色。如何更正
ca = [0 .01];
figure;
subplot(1,2,1);
scatter(x,y,10,z1); caxis(ca); colorbar;
subplot(1,2,2);
scatter(x,y,10,z2); caxis(ca); colorbar;
您看到的是caxis的正确行为。设置caxis([0 0.01])
时,大于0.01
的所有值都被指定为红色(或棕色,无论您如何称呼)。在z1
中,除最后一点外,所有点都大于0.01
,因此它们都用红色标记。如果您尝试caxis([0.1])
,您将看到右侧的绘图都是蓝色的。两个子绘图的动态范围相差一个数量级,因此,您将无法用相同的caxis限制充分表示这两个子绘图
你试过使用对数色标吗?请尝试以下操作:
subplot(1,2,1);
scatter(x,y,10,log10(z1)); colorbar;
caxis([-3 -1])
subplot(1,2,2);
scatter(x,y,10,log10(z2)); colorbar;
caxis([-3 -1])
上面的图好看吗?不错!然后,我可以将颜色栏上的勾号标签更改为1e-4
,等等。