PDA

查看完整版本 : 在Matlab中为对数图选择其他基准


poster
2019-12-10, 20:48
我想让x轴与对数2成对数:从2 ^ 10到2 ^ 25,并且每一步的指数都应增加1,而y轴应该是线性的。

这怎么可能?我已经想通了

set(gca,'XScale','log') 但是你不能设定基础。



回答:

考虑以下示例:

%# some random data x = 2.^(0:10); y = rand(size(x)); plot(log2(x), y) %# plot on log2 x-scale set(gca, 'XTickLabel',[]) %# suppress current x-labels xt = get(gca, 'XTick'); yl = get(gca, 'YLim'); str = cellstr( num2str(xt(:),'2^{%d}') ); %# format x-ticks as 2^{xx} hTxt = text(xt, yl(ones(size(xt))), str, ... %# create text at same locations 'Interpreter','tex', ... %# specify tex interpreter 'VerticalAlignment','top', ... %# v-align to be underneath 'HorizontalAlignment','center'); %# h-aligh to be centered https://i.stack.imgur.com/FdV2n.png



更多&回答... (https://stackoverflow.com/questions/3881492)