Creating a simple contour plot / Heat map
22 次查看(过去 30 天)
显示 更早的评论
I have edited this question to try to make it more clear:
As an example, I have the following arrays:
a =
1 2 3
1 2 3
b =
2 3 4
5 6 7
c =
3 4 5
6 7 8
contour(a,b,c) will give me something like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145217/image.jpeg)
I want it to look like this though:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145218/image.jpeg)
How can I fix this?
PS: Additional Confusion. On the first picture, why does the line go to put a value at (1.5,2.5)? I didnt list an (a,b) of those values together..
2 个评论
采纳的回答
Kelly Kearney
2014-8-28
编辑:Kelly Kearney
2014-8-28
pcolor(a,b,c);
shading interp;
colorbar;
The contour function plots contour lines, i.e. lines of constant value. Your function is constant across the horizontal, hence the horizontal contour lines. The contourf function would get you a bit closer to what you want, in that it shades between contour lines. But pcolor is best for showing interpolated values between your data points.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!