I have a function that create the cumulative probability that a certain time is kept (value between 0 and 1 on the Y-axis, and amount of days on the x-axis). Since I know the distance, I thought about adding a secondary x-axis with the average speed that the time correlates to.
Adding a secondary axis was relative easy like this example, as start I manage to set the xlim correct and also to reverse it.
xlabel('Time (days)')
xlim([27 38])
a1Pos = get(gca,'Position');
b = axes('Position',[a1Pos(1) a1Pos(2)-.06 a1Pos(3) a1Pos(4)], 'YTick',[],'YTickLabel',[]);
xmaxb = round(dist/(xmaxa*24));
xminb = round(dist/(xmina*24));
set(b,'Units','normalized');
set(b,'Color','none');
set(b, 'XDir','reverse')
set(b,'xlim',[xminb xmaxb])
xlabel(b,'Average speed on the journey (knots)')
There are two problems, first the rounding have too big impact and second, and more important it isn't a linear correlation between xminb and xmaxb, so I have to add the xticks manually? I tried to do it like this:
set(b,'XTick',[12 13 14 15 16 17])
Hence the now the secondary axis became empty and I don't know how to set different spacing between them (the distance between 12-13 to the right should be larger than between 16 and 17 to the left..)