So I’ve got a big matrix of data, say 100 by 100. Now I can do a nice filled contour plot by using contourf and then changing the yaxis to a log scale by using the set(gca,‘YScale’,‘log’) command, but I need a log2 axis on the y side. Is there a way I can do this easily without having to write a new function? I’ve looked through the axes properties but haven’t found anything. I’ve also thought of recreating my matrix so that the values repeat on a level of 2^whatever, but I’m not entirely sure that’s the same thing. Any other ideas?
The log[sub]2[/sub] (or to any other base) is proportional to the log[sub]10[/sub], so your contour plot will look the same under whichever base you choose. Do you just mean that you’d like the marked values along the y axis to be octaves (e.g., 1, 2, 4, 8, …) rather than decades (1, 10, 100, …)? You can do this with something like
set(gca,‘YTick’,2.^(emin:emax))
to explicitly set the tick marks. You might want to follow this with
set(gca,‘YTickLabel’,sprintf(‘2^%d’,emin:emax))
if your exponents are large enough that the powers of 2 are unwieldy to read. I don’t know of any easy way to get the exponential notation that SEMILOGY makes, though you could do that with multiple calls to TEXT.
Note that if your contour plot spans a large range in y (ymax/ymin >> 1) then the contours will not be very smooth, in the log-scaled plot, for small y (due to poor sampling there). If you are generating this matrix you may want to generate it using log-scaled spacing in the y direction (e.g., using y values of 2.^(0:0.01:1)); now a plain contour plot will be log-scaled in y, and you can then change the y labels (as above) to read as powers of 2.
Hmm… I hadn’t thought about the log[sub]10[/sub]-log[sub]2[/sub] relationship. I guess now my question is, how can I label the yaxis so that the tick marks are linearly spaced apart instead of logarithmically spaced? Would I just have to create a new axis overtop the old one and label that one?
Actually, forget the log stuff. I just realized I was told incorrect information. Anyway, this is what I actually need to plot. Say I have random data corresponding to linearly increasing x. The value of x itself corresponds inversely to another value, say w. That is x = k/w. How can I plot my data so that its arranged linearly by the w instead of by the x? Does this even make sense to anyone other than me?
Since I’ve realized the obvious and simple solution, I am asking a mod to close this. Thaks for the advice.