![]() |
在Matlab中为对数图选择其他基准
我想让x轴与对数2成对数:从2 ^ 10到2 ^ 25,并且每一步的指数都应增加1,而y轴应该是线性的。
这怎么可能?我已经想通了 set(gca,'XScale','log') 但是你不能设定基础。 [B]回答:[/B] 考虑以下示例: %# 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 [IMG]https://i.stack.imgur.com/FdV2n.png[/IMG] [url=https://stackoverflow.com/questions/3881492]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 09:01。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.