How to use clabel with log scale axes?

9 views (last 30 days)
Raptrick on 3 Nov 2014
Edited: dpb on 4 Nov 2014
Does anybody know how to get nice contourlabels (clabel) in plots with logaritmic axes. I have a workaround where I plot the log data in the contour and replace the x and ytick labels of the plot. However I am not happy with result because the labeling does work during zoom. See my example.
[x, y]=meshgrid(logspace(-3,3,1000),logspace(-2,2,800));
%some function
z = 3*(1-log10(x)).^2.*exp(-(log10(x).^2) - (log10(y)+1).^2) ...
- 10*(log10(x)/5 - log10(x).^3 - log10(y).^5).*exp(-log10(x).^2-log10(y).^2) ...
- 1/3*exp(-(log10(x)+1).^2 - log10(y).^2);
hA1 = subplot(1,1,1);
[cS hCS]=contour(x,y,z,[-6:1.5:8]);
hLS = clabel(cS,hCS);
title('cluttered contour labels, nice x and yticklabel, also when zoomed')
hA2 = subplot(1,1,1);
[cS hCS]=contour(log10(x),log10(y),z,[-6:1.5:8]);
hLS = clabel(cS,hCS);
%modify xyticklabel manualy
title('nice contour labels, messy x and yticklabel, does not work for zooming')
please try zooming
Anyone ideas how to plot nice contourlabels in contour plots with logaritmic axes?
  1 Comment
dpb on 3 Nov 2014
Edited: dpb on 4 Nov 2014
No solutions at hand, sorry, and not enough time to try to help at the moment.
I can only suggest
a) searching File Exchange and see if anybody else has had the same desire and already solved it or
b) to solve the zoom problem you'd have to write callback functions to do what you're doing now at each zoom operation.
The messy tick labels are also a pita that's been a continual pet peeve of mine that TMW didn't allow the TeX interpreter in the 'ticklabel' so you have to use text to write them formatted when faced with the problem of log axes with other than the standard decade ranges. There've been a coupld of postings on the subject with the last month or so that illustrates how to solve that minor portion of the problem.
While it probably(*) won't solve your immediate problem, I strongly suggest submitting this problem to TMW official support at for inclusion in the enhancements-needed database.
(*) It's always possible one of their handle graphics gurus just might take pity and provide workaround code if you have current support.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!