Reputation: 195
How can I plot a x-axis that just have numbers like 1,2,4,8,16,... (power of two)? I want this axis just have these numbers and no other number. I am a newbee in matlab
Upvotes: 3
Views: 2044
Reputation: 18488
You can play with the axis properties of a plot, especially xtick
and xticklabels
. The first one lets you set your own location of tick-marks, the second lets you set arbitrary labels for those ticks. Example:
x = logspace(0, log10(64), 100);
plot(x, log2(x)) % plot something
set(gca, 'xtick', (2.^(0:6))) % set ticks at 1,2,4,8,...
set(gca, 'xscale', 'log') % scale x-axis logarithmic
Upvotes: 5