xticks not working with logscale axis

조회 수: 11 (최근 30일)
Seiji Engelkemier
Seiji Engelkemier 2021년 7월 21일
답변: Seiji Engelkemier 2021년 7월 21일
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개)

Seiji Engelkemier
Seiji Engelkemier 2021년 7월 21일
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.

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by