Creating a simple contour plot / Heat map

조회 수: 43 (최근 30일)
Andrew Reibold
Andrew Reibold 2014년 8월 28일
편집: Andrew Reibold 2014년 8월 28일
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:
I want it to look like this though:
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
José-Luis
José-Luis 2014년 8월 28일
Are you trying to get isotherms?
Andrew Reibold
Andrew Reibold 2014년 8월 28일
편집: Andrew Reibold 2014년 8월 28일
If I call the arrays X, Y and Value instead, I just want to make a 'heat map' of Value where each value is at the corresponding 2d location (X,Y)
In the example above, I want the value 70 plotted at (0,10). I want the value 65 plotted at (.01,8) and so on. I want the values displayed via color. Planning for a colorbar on the side.

댓글을 달려면 로그인하십시오.

채택된 답변

Kelly Kearney
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.
  댓글 수: 1
Andrew Reibold
Andrew Reibold 2014년 8월 28일
편집: Andrew Reibold 2014년 8월 28일
Thanks Kelly, pretty much exactly what I was trying to do.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by