following recommendation in question, tried plot log2 values of data , display tick labels on horizontal , vertical axes power of 2. not getting desired tick labels along either axes. on both axes, have liked tick labels displayed integer powers of 2, i.e., on x-axis: 3 , 4, on y-axis: 0, -1, -2, -3, -4 , -5. here code:
x = [ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ] tcomm = [ 0.0357, 0.0515, 0.0745, 0.0956, 0.122, 0.1596, 0.2005, 0.2443, 0.2873, 0.3752, 0.4148, 0.5102, 0.5882 ] plot(log2(x), log2(tcomm), 'ko') set(gca, 'xticklabel',[]) %# suppress current x-labels xlim([log2(8),log2(16)]) xt = get(gca, 'xtick'); yl = get(gca, 'ylim'); str = cellstr( num2str(xt(:),'2^{%d}') ); %# format x-ticks 2^{xx} htxt = text(xt, yl(ones(size(xt))), str, ... %# create text @ same locations 'interpreter','tex', ... %# specify tex interpreter 'verticalalignment','top', ... %# v-align underneath 'horizontalalignment','center'); %# h-aligh centered xlabel('n'); ylim([log2(0.0357), log2(0.58825)]) set(gca, 'yticklabel',[]) xt = get(gca, 'ytick'); yl = get(gca, 'xlim'); str = cellstr( num2str(xt(:),'2^{%d}') ); %# format x-ticks 2^{xx} htxt = text(xt, yl(ones(size(xt))), str, ... %# create text @ same locations 'interpreter','tex', ... %# specify tex interpreter 'verticalalignment','middle', ... %# v-align underneath 'horizontalalignment','right'); %# h-aligh centered ylabel('communicationtime'); title('(a)');
for y-axis part, in text command, interchange first , second values:
xlabel('n'); ylim([log2(0.0357), log2(0.58825)]) set(gca, 'yticklabel',[]) xt = get(gca, 'ytick'); yl = get(gca, 'xlim'); str = cellstr( num2str(xt(:),'2^{%d}') ); %# format x-ticks 2^{xx} htxt = text( yl(ones(size(xt))),xt, str, ... %# create text @ same locations 'interpreter','tex', ... %# specify tex interpreter 'verticalalignment','middle', ... %# v-align underneath 'horizontalalignment','right'); %# h-aligh centered
Comments
Post a Comment