I want to plot a semilogy
graph, and for that purpose I have something like this:
figure
semilogy(data_1(:,1), data_1(:,2), 'sb-', 'LineWidth', 2);
hold on
semilogy(data_2(:,1), data_2(:,2), 'mp-', 'LineWidth', 2);
grid on
axis([0 20 10^-4 10^0])
axis([0 20 10^-4 10^0])
This works all find and plots things, but the x-axis
has interval of 5. What I mean is that values in the x-axis
are labeled as 0, 5, 10, 15, 20
, whereas I want them to have interval of 2, meaning to be labeled as 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20
. On the other hand, y-axis
works fine, and it goes as 10^-0, 10^-1, 10^-2, 10^-3, 10^-4
, which is exactly what I want. How can I change the interval on just the x-axis
?
Add the following line after plotting:
set(gca,'XTick', 0:2:20);