Search code examples
matlabplotaxessubplot

Show only predefined value in axes MATLAB


I would like to only show these x-values on the x-axes

 xx=[0.0005 0.005 0.05 0.1 0.25 0.5 0.75 1 1.25 1.5];

Is it possible?


Solution

  • You can modify axis labels using XtTickLabel property. For example:

    set(gca,'XTickLabel',[0.0005 0.005 0.05 0.1 0.25 0.5 0.75 1 1.25 1.5])
    

    This will change only labels, not actual values on the plot. To check values as well you can use:

    set(gca,'XTick',[0.0005 0.005 0.05 0.1 0.25 0.5 0.75 1 1.25 1.5]);
    set(gca,'XScale','log');  % Your xx values seem to be logarithmic, so this can help.