Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
我想让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 ![]() 更多&回答... |
![]() |
![]() |