xticks not working with logscale axis

I'd like to show a log scale number line with some non-overlapping rectangles spanning the line. I'm having issues with showing only a subset of tick marks of the xlim range that I set. Despite specifying the xticks, all the ticks are shown (as would be if 'auto' was used). There's no issue if the xscale is linear, so I'm wondering if this is a bug.
Probably not relevant, I'm choosing to label only a few tick marks.
figure
% rectangle(...)
xlim([0.8 1100])
x_s = [(1:9)*10^0 (1:9)*10^1, (1:9)*10^2, 10^3]';
xticks(x_s)
x_labels = repmat({''},length(x_s),1);
x_labels([1, 10, 19, 28]) = num2cell([1 10 100 1000]);
xticklabels(x_labels)
set(gca, 'XScale','log')

回答(1 个)

Still curious if there's an answer, but I solved my problem by plotting a horizontal line, plotting vertical bars for tick marks, text() for the tick labels, and setting x-axis color to none.

类别

帮助中心File Exchange 中查找有关 Axis Labels 的更多信息

产品

版本

R2021a

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by