How do I replace NaN values in contourf with another plot?
古いコメントを表示
I am using contourf to plot salinity over a large region. Data only shows over ocean, so I was hoping to show an outline of the shoreline where NaN values appear on the contour. I've created a representative example in the following code:
X=rand(30,60);
X(10:25,10:30) = NaN;
figure();
subplot(2,1,1)
load coast;
lat2=[nan;lat;nan; lat];
long2=[nan;long; nan; long+360];
plot(long2,lat2,'k','linewidth',1)
axis([260 320 0 30]);
subplot(2,1,2)
contourf(X)
This example creates two subplots: the first shows the shorelines, the second shows contours with a hole (due to NaN values). I want to create one plot that shows the filled contours on top with the shorelines peaking through the hole.
I have tried making the NaN values transparent, but wasn't getting anywhere. Any help would be greatly appreciated!
2 件のコメント
Star Strider
2016 年 10 月 14 日
Are you going to share ‘coast’, ‘lat’ and ‘lon’ with us?
Does this require the Mapping Toolbox? If so, please add that in the Product Tags.
Also, your axis call is perplexing, because ‘0’ and ‘30’ as integers can be represented exactly in binary form. No rounding is necessary.
Jonathan Whiting
2016 年 10 月 17 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Vector Fields についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!