我有两个变量(z1和z2),它们是x和y的函数。 我想使用相同的颜色条在两个子图中绘制它们。 这两个变量具有不同的最小值和最大值。 所以,我想将颜色条定义为(z1,z2)的最小值,并以(z1,z2)的最大值结束。 因此我使用:
figure=scf(); figure.color_map=jetcolormap(32); subplot1=subplot(121); surf(x,y,z1); subplot2=subplot(122); surf(x,y,z2); colorbar(min(min(min(z1)),min(min(z2))),max(max(max(z1)),max(max(z2))));但是这样做,我使用他们自己的颜色条得到两个图,分别对应于它们的最小值和最大值。 我知道我们可以在Matlab上使用属性作为caxis和climb来获得这种行为。 但我不知道Scilab相当于这些属性。
如果用Scilab的基本版本无法做到这一点,请你告诉我一些Scilab允许这样做的图书馆。
谢谢你的帮助。
I have two variables (z1 and z2) which are function of x and y. I would like to plot them in two subplot using the same colorbar. These two variables have different min and max value. So, I would like define the colorbar as begining by the min of (z1,z2) and finishing by the max of (z1,z2). Therefore I use:
figure=scf(); figure.color_map=jetcolormap(32); subplot1=subplot(121); surf(x,y,z1); subplot2=subplot(122); surf(x,y,z2); colorbar(min(min(min(z1)),min(min(z2))),max(max(max(z1)),max(max(z2))));But doing like this, I get two graph using theirs own colorbar which correspond respectively to their min and max. I know that we can get this behaviour on Matlab using properties as caxis and clim. But I don't know the equivalent of these properties for Scilab.
If it's not possible to do this with the basic version of Scilab, could you please advise to me some libraries Scilab permitting to do this.
Thanks for your help.
最满意答案
您可以尝试将cdata_mapping从“scaled”更改为“direct”,并根据实际使用的范围缩放颜色矩阵(定义每个facet的颜色):
x=[0:0.3:2*%pi]; //example data [X,Y]=ndgrid(x,x); Z1=sin(x')*cos(x); //first data set Z2=Z1./2; //second dataset is half in amplitude Zmin=min(min(Z1),min(Z2)); //Absolut minimum of all data sets Zmax=max(max(Z1),max(Z2)); //Absolut maximum of all data sets nc=100; //number of colors in colormap tabl=scf(); tabl.color_map=jetcolormap(nc); subplot(1,2,1); surf(X,Y,Z1); h=gce(); cm=h.data.color; //color matrix h.data.color=((cm-Zmin)./(Zmax-Zmin)).*(nc-1)+1; //scale color matrix & convert to color number h.cdata_mapping="direct"; //change color mapping from 'scaled' to 'direct' colorbar(Zmin,Zmax); subplot(1,2,2); surf(X,Y,Z2); h=gce(); cm=h.data.color; //color matrix h.data.color=((cm-Zmin)./(Zmax-Zmin)).*(nc-1)+1; //scale color matrix & convert to color number h.cdata_mapping="direct"; //change color mapping from 'scaled' to 'direct' colorbar(Zmin,Zmax);You may try to change the cdata_mapping from 'scaled' to 'direct' and scale the color matrix (which defines the color of each facet) according to the actual range used:
x=[0:0.3:2*%pi]; //example data [X,Y]=ndgrid(x,x); Z1=sin(x')*cos(x); //first data set Z2=Z1./2; //second dataset is half in amplitude Zmin=min(min(Z1),min(Z2)); //Absolut minimum of all data sets Zmax=max(max(Z1),max(Z2)); //Absolut maximum of all data sets nc=100; //number of colors in colormap tabl=scf(); tabl.color_map=jetcolormap(nc); subplot(1,2,1); surf(X,Y,Z1); h=gce(); cm=h.data.color; //color matrix h.data.color=((cm-Zmin)./(Zmax-Zmin)).*(nc-1)+1; //scale color matrix & convert to color number h.cdata_mapping="direct"; //change color mapping from 'scaled' to 'direct' colorbar(Zmin,Zmax); subplot(1,2,2); surf(X,Y,Z2); h=gce(); cm=h.data.color; //color matrix h.data.color=((cm-Zmin)./(Zmax-Zmin)).*(nc-1)+1; //scale color matrix & convert to color number h.cdata_mapping="direct"; //change color mapping from 'scaled' to 'direct' colorbar(Zmin,Zmax);更多推荐
发布评论