フィルターのクリア

How to hold colorbar in contourf plot

2 ビュー (過去 30 日間)
Sonima
Sonima 2013 年 1 月 14 日
Hello everyone
I want to plot a contorf plot in logaritmic scale. first I want to plot in normal to provide colorbar, then hold the colorbar and scale the datas to log10 and plot again. this is the code:
contourf(a,b,c);
h = colorbar('YScale','log');
hold(h);
d = log10(c);
cla
contourf(a,b,d);
but the colorbar doesn't hold and when I re plot the the contourf, the colorbar is disappear, and if i plot the colorbar again, then it is shows the colorbar of new contourf which is wrong.
So, how can I plot the colorbar of the first contourf on the second plot of contourf? how can I hold or keep the colorbar? thanks.

採用された回答

Shashank Prasanna
Shashank Prasanna 2013 年 1 月 14 日
I haven't tried this entirely, but instead of cla and replotting try
figure(1)
contourf(1,b,c)'
h = colorbar('YScale','log');
d = log10(c);
figure(2)
contourf(a,b,d)
a = get(1,'children');
copyobj(a(1),2);
This is a crude reparenting of the colorbar from the original figure to the new one.

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by