如何在 Scilab 中为两个子图设置单独的颜色图?
How can I have separate colormaps for two subplots in Scilab?
我有两个由 surf 制作的子图,因为两个绘制的变量具有非常不同的行为和比例,我想用独立的颜色图绘制它们。我尝试按如下方式对其进行编码,但最后一个颜色图是应用于所有内容的颜色图。我怎样才能使每个子图获得不同的颜色图?我目前使用此代码获得的图像是 this.
---- START OF CODE BLOCK ----
f0=scf(0);
subplot(1,3,1);
surf(plotPlan(:,:),N(:,:));
f0.color_map = jetcolormap(32);
xtitle("NUTRIENT SPATIAL DYNAMICS","NBY","NBX","Z");
set(gca(),"auto_clear","off");
subplot(1,3,2);
surf(plotPlan(:,:),A(:,:));
f0.color_map = oceancolormap(32);
xtitle("ALGAE SPATIAL DYNAMICS","NBY","NBX","Z");
set(gca(),"auto_clear","off");
...
---- END OF CODE BLOCK ----
color_map 属性 附在图中,因此无法为每个轴设置颜色图。
然而,可以按照下面的示例做你想做的事
function c=colorindex(z,ncolor)
//compute the color index for each surface value
mn=min(z);mx=max(z)
c=round((z-mn)/(mx-mn)*(ncolor-1))+1
endfunction
//first surface
t=linspace(0,2*%pi,30);
z1=sin(t)'*cos(t);
//second one
z2=z1.*z1;
f=scf(0);clf;
defined a colormap with the catenation of the 2 requested colormaps
f.color_map=[jetcolormap(32);oceancolormap(32)];
//draw the first surface with the first part of the colormap
subplot(211);surf(z1,colorindex(z1,32),"ColorDataMapping","direct")
//draw the second surface with the second part of the colormap
subplot(212);surf(z2,colorindex(z2,32)+32,"ColorDataMapping","direct")
我有两个由 surf 制作的子图,因为两个绘制的变量具有非常不同的行为和比例,我想用独立的颜色图绘制它们。我尝试按如下方式对其进行编码,但最后一个颜色图是应用于所有内容的颜色图。我怎样才能使每个子图获得不同的颜色图?我目前使用此代码获得的图像是 this.
---- START OF CODE BLOCK ----
f0=scf(0);
subplot(1,3,1);
surf(plotPlan(:,:),N(:,:));
f0.color_map = jetcolormap(32);
xtitle("NUTRIENT SPATIAL DYNAMICS","NBY","NBX","Z");
set(gca(),"auto_clear","off");
subplot(1,3,2);
surf(plotPlan(:,:),A(:,:));
f0.color_map = oceancolormap(32);
xtitle("ALGAE SPATIAL DYNAMICS","NBY","NBX","Z");
set(gca(),"auto_clear","off");
...
---- END OF CODE BLOCK ----
color_map 属性 附在图中,因此无法为每个轴设置颜色图。 然而,可以按照下面的示例做你想做的事
function c=colorindex(z,ncolor)
//compute the color index for each surface value
mn=min(z);mx=max(z)
c=round((z-mn)/(mx-mn)*(ncolor-1))+1
endfunction
//first surface
t=linspace(0,2*%pi,30);
z1=sin(t)'*cos(t);
//second one
z2=z1.*z1;
f=scf(0);clf;
defined a colormap with the catenation of the 2 requested colormaps
f.color_map=[jetcolormap(32);oceancolormap(32)];
//draw the first surface with the first part of the colormap
subplot(211);surf(z1,colorindex(z1,32),"ColorDataMapping","direct")
//draw the second surface with the second part of the colormap
subplot(212);surf(z2,colorindex(z2,32)+32,"ColorDataMapping","direct")