How to remove scientific notation from axes labels on log-log plot, and add thousands separator?
Show older comments
I am having difficulty making a plot with log-log axes where the axis labels are in fixed notation, not scientific notation, and commas are used as the thousands separator. After creating the plot and converting the axes to log scale, I was able to convert the axes to fixed notation using 3 methods:
1) Specifying the ticks
xtick = [1 10 100 1000];
xticks(xtick);
xticklabels(xtick);
2) xt = ax.XTick;
xt_sigfig = round(xt, 3, 'significant');
ax.XTickLabel = xt_sigfig;
3) using "compose" function
ax.XAxis.TickLabels = compose('%g', ax.XAxis.TickValues)
However, I was unable to add a thousands separator using any of those methods. For instance I would like the x tick labels to read: 1 10 100 and 1,000. And I would like the y tick labels to read: 1 10 100 1,000 10,000 and 100,000. My data and code are below using the "compose" function. Do I have to create tick labels that are strings? Any help would be greatly appreciated.
% X values
Q=[20.09 0.67 61.43 33.54 167.35 142.88 3.27 39.00 55.82 134.59 58.88 1.25 0.15 12.80 5.09 23.18 18.56 84.19 22.23 15.80 28.97 48.91 2.60 65.69 107.82]
% Y values
S=[4190 60.10 56700 39900 82000 17700 26.40 12800 135000 20100 8420 7.14 39.40 329 253 5870 4270 23400 2320 5560 9210 107000 27.40 15700 17200]
plot(Q,S,'o');
axis([0 1000 0 200000]);
set(gca,'XScale','log');
set(gca,'YScale','log');
ax=gca;
ax.XAxis.TickLabels = compose('%g', ax.XAxis.TickValues)
ax.YAxis.TickLabels = compose('%g', ax.YAxis.TickValues)
Accepted Answer
More Answers (0)
Categories
Find more on Axis Labels 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!
