MATLAB Answers

How to hold colorbar in contourf plot

6 views (last 30 days)
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:
h = colorbar('YScale','log');
d = log10(c);
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.

Accepted Answer

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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!