在MATLAB中绘制等高线图上的零值 [英] Plot Zero Value on Contour Plot in MATLAB
本文介绍了在MATLAB中绘制等高线图上的零值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在等高线图上绘制0到10的z值.
I'm plotting z values, 0 to 10, on a contour plot.
当我包含1或更大的数据时,我得到了一个等高线图.如下所示:
When I include data 1 or greater, I obtain a contour plot. Like the following:
longitude = [80 82 95]
latitude = [30 32 35]
temp = [1 4 6; 1 2 7; 3 5 7]
contourf(longitude,latitude,temp)
现在,我想在轮廓图上绘制零值.当我期望一种颜色代表零值时,却获得了一个白色正方形.
Now, I want to plot the ZERO VALUE also on the contour plot. While I was expecting one color representing the zero value, instead I obtained a white square.
longitude = [80 82 95]
latitude = [30 32 35]
temp = [0 0 0; 0 0 0; 0 0 0]
contourf(longitude,latitude,temp)
非常感谢, 阿曼达
推荐答案
如Issac所述.在contourf
中绘制常量数据是不可能的.
As Issac mentioned. To plot a constant data in a contourf
is not possible.
当您尝试这样做时,您将从Matlab获得此警告:
When you try to do so you will obtain this warning from Matlab:
temp =
0 0 0
0 0 0
0 0 0
Warning: Contour not rendered for constant ZData
> In contourf>parseargs at 458
In contourf at 63
In TESTrandom at 45
但是,如果将一些数字设置为0,contourf可以正常工作:
However, if you put some numbers as 0, the contourf works fine:
longitude = [80 82 95];
latitude = [30 32 35];
temp = [0 4 6; 1 0 7; 0 5 9];
contourf(longitude,latitude,temp);
hcb = colorbar('horiz'); % colour bar
set(get(hcb,'Xlabel'),'String','Contourf Bar.')
这篇关于在MATLAB中绘制等高线图上的零值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文