I want a 2D plot, Y-axis with base 10 logarithm scale,
while X-axis with base 2 logarithm scale.
For example:
set(gca, 'YScale', 'log', 'XScale', 'log');
set(gca, 'YLim', [1e1 1e3], 'YTick', [1e0 1e1 1e2 1e3])
set(gca, 'XLim', [4 40], 'XTick',[4 8 16 32], 'XTickLabel', {'2^2'; '2^3'; '2^4'; '2^5'});
However, the X-ticks look ugly. I want the numbers 3, 4, 5, etc to appear as exponents.
Any idea how to make this picture look nicely?
Many thanks.
Look at documentation in text function or title function.
I _THINK_ is also honored in axis labels...
--
Well, unfortunately, at least w/ R12 set(gca,... for tick labels did
_NOT_ honor the carat for exponentiation.
Maybe someone from TMW can comment if ML still doesn't recognize the
idiom in your version.
Sorry, other that freeform text (a real pita to get right) I've no other
ideas for you...
> --
You can use tick2text, from the FEX:
http://www.mathworks.com/matlabcentral/fileexchange/16003
set(gca, 'YScale', 'log', 'XScale', 'log');
set(gca, 'YLim', [1e1 1e3], 'YTick', [1e0 1e1 1e2 1e3])
set(gca, 'XLim', [4 40], 'XTick',[4 8 16 32]);
tick2text(gca, 'axis', 'x', 'xformat', @(x) sprintf('2^%d', log2(x)));
I just updated tick2text to work properly on logarithmically scaled axes, which I had overlooked in my original version, so you may have to wait a day or two for the updated version to appear on the FEX.
-Kelly