如何在Scilab中为两个子图提供单独的色彩映射?

时间:2015-12-17 13:53:29

标签: plot 3d surface scilab colormap

我有两个由冲浪制作的子图,因为两个绘制的变量具有非常不同的行为和尺度,我想用独立的颜色图绘制它们。我尝试将其编码如下,但最后一个颜色图是应用于所有内容的颜色图。我怎样才能使每个子图获得不同的色彩图?我目前使用此代码获得的图片为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 ----

1 个答案:

答案 0 :(得分:1)

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