0
votes

I have a plot of some data that I believe should be approximate log^2(n) = log(n)^2. I want to plot n on the horizontal axis and the data on the vertical axis, but I want to scale the horizontal axis by log^2 so that I get approximately a straight line. Now, I know how to do this with just log instead of log^2 (eg, use semilogx), but I don't know how to do it for log^2.

I tried doing set(gca,'xscale','log') to give log scaling, and then running the same thing again, hoping that this would rescale by log again. Unfortunately it didn't. (I believe) the only options for 'xscale' are linear and log.

I've had a look around the usual forums (via a Google search), but I can't find the solution. There's lots on the question of just log scaling, and there's some on changing the base of the logarithm (not what I want to do). Any advice on this matter would be most appreciated! Thanks


Let me just add a clarification. In probability theory (which is what I do), it's common to write log^2(n) for log(n)^2. You talk about a mixing time being "log squared"; so this notation means that you can drop the n and still say ~ log^2. So I believe my data is approximate log(n)^2.

1

1 Answers

1
votes

I believe your are right about the xscale options. These are regular axes to use in plots. If you want your data to show up as a straight line, change your data in stead by taking log of your x-values, when you plot. Just remember to change xlabel accordingly to show what you have done.

E.g.

plot([1,10,100],[3,2,1])
set(gca,'xscale','log')
xlabel('x')

can be shown as

plot(log10([1,10,100]),[3,2,1])
xlabel('log10(x)')

EDIT: You can alter XTick and XTickLabel manually like this in stead

set(gca,'XTick',log10(x))
set(gca,'XTickLabel',{'10^0','10^1','10^2'})