Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom axis scales - "Reverse" logarithmic?

Sorry about the poor title ;)

I'm trying to recreate a matlab plot I've come across in some other work, but I don't quite understand the scale they are using. The y axis increments are as follows (from the top [+ve y]):

0.9999, 0.999, 0.99, 0.9, 0

I can use semilogy to plot a logarithmic graph, but this is kind of the wrong way round; my increments go

1, 0.1, 0.01, 0.001, etc

which is actually 1 - i, where i is the increments I actually want! I don't entirely understand how to describe this type of plot anyway; can anyone help?

like image 698
robf Avatar asked Mar 22 '11 17:03

robf


1 Answers

To plot the axes the way you want to, you have to do three steps: (1) plot 1-y, (2) reverse axes (3) relabel axes

y = [0.4 0.8 0.99 0.9999];

%# plot 1-y 
plot(1-y) %# alternatively use semilog, then you won't have to adjust 'yscale' below

%# reverse y-axis
set(gca,'ydir','reverse','yscale','log')

%# if necessary, set the axis limits here

%# relabel y-axis
set(gca,'yticklabel',num2str(1-10.^str2num(get(gca,'yticklabel'))))

enter image description here

like image 179
Jonas Avatar answered Sep 30 '22 14:09

Jonas