Threshold contour without changing colormap

3 ビュー (過去 30 日間)
Sylvia
Sylvia 2015 年 10 月 30 日
コメント済み: Sylvia 2015 年 11 月 4 日
How can I create a threshold contour without changing an existing colormap? Here is my code:
figure(1)
hold on
m_contourf(lon,lat,(ndustaCNT)',40,'LineStyle','none');
m_contourf(lon,lat,(ndustaCNT)',[0 0],'Color','w');
m_coast('line','Color','k');
m_grid('xtick',10,'tickdir','out','yaxislocation','left','fontsize',10);
c3 = colorbar('WestOutside');
I want to keep the colormap associated with the ndustaCNT matrix but overlay a single white contour where values equal zero. When I add in the second m_contourf line, the colormap changes and I lose all the structure. Thanks for your help. - Sylvia

回答 (1 件)

Chad Greene
Chad Greene 2015 年 11 月 1 日
The freezeColors function on file exchange should solve this problem.
figure(1)
hold on
m_contourf(lon,lat,(ndustaCNT)',40,'LineStyle','none');
freezeColors;
m_contourf(lon,lat,(ndustaCNT)',[0 0],'Color','w');
m_coast('line','Color','k');
m_grid('xtick',10,'tickdir','out','yaxislocation','left','fontsize',10);
c3 = colorbar('WestOutside');
  1 件のコメント
Sylvia
Sylvia 2015 年 11 月 4 日
Thanks, I've used freezeColors before and it works very well between subplots, but I've never used it within a single subplot. Actually I just used m_contour rather than m_contourf to make this work:
figure(1)
hold on
m_contourf(lon,lat,(ndustaCNT)',40,'LineStyle','none');
m_contour(lon,lat,(ndustaCNT)',[0 0],'Color','w');
m_coast('line','Color','k');
m_grid('xtick',10,'tickdir','out','yaxislocation','left','fontsize',10);
c3 = colorbar('WestOutside');

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by