user3304195
user3304195

Reputation: 11

semilog plot: axes will not stay consistent

I am trying to get 5 different semi log x figures for 5 data sets (and each figure has a number of lines on its plot). The plot works well when I don't enter any data (i.e. the axis ranges are what I want them to be) but when I enter data, the axes ranges changes (the limits stay the same, but the spacing between different values changes). For example, for the first data set, I input it and 10^2 appears about 1/4 of the way across the x-axis, but I input the second data set and 10^2 appears 1/2 of the way across the x-axis. How can I get the axes to stay perfectly consistent regardless of whether the data changes?

My code is below:

function createfigure_log_orient_autocorr(X1, YMatrix1)

plot(X1,YMatrix1,'LineWidth',2);

set(gca,...
    'YTickLabel',['0  ';'0.2';'0.4';'0.6';'0.8';'1  '],...
    'YTick',[0 0.2 0.4 0.6 0.8 1],...
    'XTickLabel',['0';'1';'2';'3'],...
    'XTick',[1 10 100 1000],...
    'XScale','log',...
    'XMinorTick','on',...
    'PlotBoxAspectRatioMode','manual',...
    'PlotBoxAspectRatio',[1.999 1 0.5],...
    'FontWeight','bold',...
    'FontSize',16,...
    'DataAspectRatioMode','manual',...
    'DataAspectRatio',[1000 1 2],...
    'XLimMode','manual',...
    'XLim', [0 2000],...
    'YLimMode', 'manual',...
    'YLim', [0,1]);

I understand my question may be confusing, so I can try to clarify if anyone needs me to.

Upvotes: 1

Views: 1138

Answers (1)

Lazarus
Lazarus

Reputation: 358

I'd use the function semilogx(...) instead of plot, and then follow it up with axis to set the limits I want.

More here.

Upvotes: 0

Related Questions