【发布时间】:2016-10-24 04:46:01
【问题描述】:
我有这个显示两个等高线图的漂亮代码。我想知道是否可以以连续方式而不是离散方式显示颜色栏中的所有颜色?这是下面的代码,谢谢:
[r,x] = meshgrid(1:0.01:50,-1:0.01:5);
am=(1/4)*(r+(1./r)).*((1-x.^2).^-0.5);
num=2+( x.*(r+(1./r)) );
dem=(r-(1./r)).*((1-x.^2).^0.5);
G=am.*EA(num./dem);
test=G;
test(G<0)=nan;
test(x==1)=test(x==0);
figure
contourf(log10(r),x,test,'LevelList', [-inf,0,1,2,3,4,5,inf]);
h=colorbar;
set(get(h,'ylabel'),'string',' \gamma P_pL','FontSize',18)
xlabel('$log_{10}(r)$','Interpreter','latex','FontSize',18)
ylabel('$D/2\sqrt{M}$','Interpreter','latex','FontSize',18)
set(gca,'fontsize',18)
sigpm=1- (2./(r+(1./r)));
DEm=1+((1-sigpm).*x);
sig0=sigpm./DEm;
figure
contourf(sigpm*100,sig0*100,test,'LevelList', [-inf,0,1,2,3,4,5,inf]);
h=colorbar;
set(get(h,'ylabel'),'string',' \gamma P_pL','FontSize',18)
xlabel('$\sigma_\pm$','Interpreter','latex','FontSize',18)
ylabel('$\sigma_0$','Interpreter','latex','FontSize',18)
set(gca,'fontsize',18)
xlim([0 20])
【问题讨论】:
-
colormap(jet(256)) -
我收到错误消息:
Undefined function or variable 'EA'.,您能发布一个可执行代码吗?您还可以在帖子中添加图片。 -
如果您想要更多颜色,请按照@obchardon 的建议执行并使用更大的数字调用颜色图,但pleaseeeeee 不要使用
jet,使用类似parula 的东西,或者任何或其他更好的颜色图。 -
抱歉 ROtem 将 EA(num./dem) 替换为 acot(num./dem)
-
我的问题的答案就是以下 v=[0:0.25:5];图轮廓f(log10(r),x,test,'LevelList',v);这样我就可以在同一个颜色栏中显示更多颜色:)
标签: matlab plot matlab-figure contourf