Why won't my x-axis tick label format change?
Show older comments
Hello,
I have provided my code and the figure it creates in this post. I've tried everything that I know of to change the x-axis numbers on the graph. I have tried xtickformat, ax = gca, ax.XAxis.Exponent = 0 and ax.XTickLabelMode = 'manual'.
My goal is to make the x-axis tick values appear like: "10, 1, 0.1, 0.001" etc. instead of containing exponent values.
If anybody could give me guidance on where my code is causing the trouble or a function I am unaware of that can help me solve this problem it would be greatly appreciated! I am fairly new to MatLab and am really enjoying it so any tips in general to imrpove this short code is also appreciated.
% Perecent passing
y = [100 99.69 99.69 99.62 99.48 99 98.65 91.09 73.63 ...
73.28 70.09 68.50 66.91 60.53 57.35 52.57 49.38 ...
47.79 44.60 43.01 41.42];
% Particle diameter (mm)
x = [19 9.5 4.76 2 0.85 0.42 0.3 0.149 0.075 0.0698 ...
0.0391 0.0284 0.0197 0.0140 0.0105 0.0075 0.0054...
0.0038 0.0031 0.0026 0.0011];
semilogx(x,y,'linewidth',0.85)
xlim([0.001 100]);
ylim([0 100]);
ax = gca;
set(ax, 'XDir','reverse');
ytickformat('%g%%');
title('Grain Size Analysis: Clayey Soil','FontWeight','normal');
ylabel('Percent passing','FontSize',12);
xlabel('Grain size (mm)','FontSize',12);
grid
l1 = yline(73.63,'--k',{'Silt sized','particles'});
l2 = yline(42,'--k',{'Clay sized','particles'});
l1.LabelVerticalAlignment = 'middle';
l1.LabelHorizontalAlignment = 'center';
l2.LabelVerticalAlignment = 'middle';
l2.LabelHorizontalAlignment = 'center';

Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!