Change Default White for Zero in Contour Plot
古いコメントを表示
How can I change the default white for zero for the output of a contour plot to a different color?
longitude = [80 82 95]
latitude = [30 32 35]
temp = [0 0 0; 0 0 0; 0 0 0]
contourf(longitude,latitude,temp)
Thanks,
Amanda
1 件のコメント
Walter Roberson
2012 年 11 月 27 日
採用された回答
その他の回答 (2 件)
Walter Roberson
2012 年 11 月 27 日
contourf() does not default to white for 0. contourf() defaults to the first entry in the active colormap for the smallest value in the data. If that smallest value happens to be 0, then you can change the color by changing the colormap. For example,
colormap(hot)
2 件のコメント
Amanda
2012 年 11 月 27 日
Walter Roberson
2012 年 11 月 27 日
You don't. If your array is constant data, contourf() will not plot it at all. You need to use at least two distinct values.
Are you really trying to plot a contour for an all-zero matrix, or are you trying to plot the z=0 plane to add to an existing contour plot?
houda
2016 年 8 月 2 日
0 投票
Hi,
I have the same problem. I have a matrix which change value, so when it contains non constant value it is okay, but when it contains the same value (1 or 0) I want to have either the color corresponding to 1 or to 0. I know that the problem is that contourf don't calculate it that is why I have nothing, but there is any other function to have what I want ?
Thank you for your help!
1 件のコメント
Walter Roberson
2016 年 8 月 2 日
image() the constant array if length(unique(TheArray(:)))==1
カテゴリ
ヘルプ センター および File Exchange で Contour Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!