countourf没有在Matlab中显示彩色区域

时间:2017-06-03 16:44:30

标签: matlab matlab-figure

我的代码中应该更改哪些countorf显示颜色差异较大的区域?

clear all;
close all;
phi=90;
[xx,yy] = meshgrid(-20:0.1:20,-20:0.1:20);
Idontwantthis = (xx.^2+yy.^2)<0.1;
u = (xx./(xx.^2+yy.^2).^(3/2));
v = (yy./(xx.^2+yy.^2).^(3/2));
data= sqrt(u.^2+v.^2);
data(Idontwantthis)=NaN;
u(Idontwantthis)=NaN;
v(Idontwantthis)=NaN;
contourf(xx,yy,data,20);

1 个答案:

答案 0 :(得分:0)

首先,[-20 20]超过[-2 2]。尝试将范围缩小到contourf。运行clear all; close all; phi=90; [xx,yy] = meshgrid(-2:0.01:2,-2:0.01:2); Idontwantthis = (xx.^2+yy.^2)<0.1; u = (xx./(xx.^2+yy.^2).^(3/2)); v = (yy./(xx.^2+yy.^2).^(3/2)); data= sqrt(u.^2+v.^2); data(Idontwantthis)=NaN; u(Idontwantthis)=NaN; v(Idontwantthis)=NaN; contourf(xx,yy,data,20); colormap hsv; 后,更改colormap:

.osm.pbf

这就是你的结果: contour plot with hsv colormap

希望有所帮助!